DEV: Accquire file lock before checking if selenium webdriver cache (#25534)
Why this change? We are getting the following error on CI: `Text file busy - /github/home/.cache/selenium/chromedriver/linux64/121.0.6167.85/chromedriver` This happens when two processes tries to download the chromedriver at the same time. I'm not entirely sure why the previous implementatio is not locking properly since we still saw the `Text file busy` error but by accquring the lock before we even check for the existence of `~/.cache/selenium`, we should be able to eliminate the chance of two processes trying to download the chromedriver binary at the same time.
This commit is contained in:
parent
140b2118af
commit
06b7a6bd59
|
@ -572,9 +572,10 @@ RSpec.configure do |config|
|
||||||
#
|
#
|
||||||
# The long term fix here is to get `selenium-manager` to download the `chromedriver` binary to a unique path for each
|
# The long term fix here is to get `selenium-manager` to download the `chromedriver` binary to a unique path for each
|
||||||
# process but the `--cache-path` option for `selenium-manager` is currently not supported in `selenium-webdriver`.
|
# process but the `--cache-path` option for `selenium-manager` is currently not supported in `selenium-webdriver`.
|
||||||
if !File.directory?(File.expand_path("~/.cache/selenium"))
|
File.open("#{Rails.root}/tmp/chrome_driver_flock", File::RDWR | File::CREAT, 0644) do |file|
|
||||||
File.open("#{Rails.root}/tmp/chrome_driver_flock", File::RDWR | File::CREAT, 0644) do |file|
|
file.flock(File::LOCK_EX)
|
||||||
file.flock(File::LOCK_EX)
|
|
||||||
|
if !File.directory?(File.expand_path("~/.cache/selenium"))
|
||||||
`#{Selenium::WebDriver::SeleniumManager.send(:binary)} --browser chrome`
|
`#{Selenium::WebDriver::SeleniumManager.send(:binary)} --browser chrome`
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue