webdriver_manager icon indicating copy to clipboard operation
webdriver_manager copied to clipboard

ChromeDriverManager().install() occasionally fails with "zipfile.BadZipFile: File is not a zip file" when called concurrently

Open gdlxn-ibm opened this issue 2 months ago • 0 comments

I have a Python that concurrently calls ChromeDriverManager().install() in subprocesses. I've found that ChromeDriverManager().install() occasionally fails with "zipfile.BadZipFile: File is not a zip file" when called concurrently:

concurrent.futures.process._RemoteTraceback: """ Traceback (most recent call last): File "/usr/lib/python3.12/concurrent/futures/process.py", line 263, in _process_worker r = call_item.fn(*call_item.args, **call_item.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gdlxn/nirvana-status-page/NIRVANAZOS-6501/concurrent-selenium-get-timing.py", line 130, in get_url web_driver = ConcurrentSeleniumGetTiming.get_chrome_web_driver() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gdlxn/nirvana-status-page/NIRVANAZOS-6501/concurrent-selenium-get-timing.py", line 125, in get_chrome_web_driver service = Service(ChromeDriverManager().install()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gdlxn/nirvana-status-page/NIRVANAZOS-6501/.venv/lib/python3.12/site-packages/webdriver_manager/chrome.py", line 40, in install driver_path = self._get_driver_binary_path(self.driver) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gdlxn/nirvana-status-page/NIRVANAZOS-6501/.venv/lib/python3.12/site-packages/webdriver_manager/core/manager.py", line 41, in _get_driver_binary_path binary_path = self._cache_manager.save_file_to_cache(driver, file) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gdlxn/nirvana-status-page/NIRVANAZOS-6501/.venv/lib/python3.12/site-packages/webdriver_manager/core/driver_cache.py", line 54, in save_file_to_cache files = self.unpack_archive(archive, path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gdlxn/nirvana-status-page/NIRVANAZOS-6501/.venv/lib/python3.12/site-packages/webdriver_manager/core/driver_cache.py", line 49, in unpack_archive return self._file_manager.unpack_archive(archive, path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gdlxn/nirvana-status-page/NIRVANAZOS-6501/.venv/lib/python3.12/site-packages/webdriver_manager/core/file_manager.py", line 57, in unpack_archive return self.__extract_zip(archive_file, target_dir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gdlxn/nirvana-status-page/NIRVANAZOS-6501/.venv/lib/python3.12/site-packages/webdriver_manager/core/file_manager.py", line 63, in __extract_zip archive = zip_class(archive_file.file_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/zipfile/init.py", line 1349, in init self._RealGetContents() File "/usr/lib/python3.12/zipfile/init.py", line 1416, in _RealGetContents raise BadZipFile("File is not a zip file") zipfile.BadZipFile: File is not a zip file """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/gdlxn/nirvana-status-page/NIRVANAZOS-6501/concurrent-selenium-get-timing.py", line 179, in ConcurrentSeleniumGetTiming.perform_selenium_get_timing() File "/home/gdlxn/nirvana-status-page/NIRVANAZOS-6501/concurrent-selenium-get-timing.py", line 170, in perform_selenium_get_timing future_results = [future.result() for future in futures] ^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception zipfile.BadZipFile: File is not a zip file

Rerunning the script usually resolves the problem.

gdlxn-ibm avatar Oct 06 '25 18:10 gdlxn-ibm