Fix of "OSError: [WinError 6] The handle is invalid"

This error seems to be a problem for a lot of users of the package. Adding a try-except block is solving the issue for them while keeping it functional for the others as well.

Source: https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/955
This commit is contained in:
Enes Görkem Genç 2023-06-12 22:47:57 +03:00
parent 1c704a71cf
commit 35c6e786ef
1 changed files with 5 additions and 1 deletions

View File

@ -782,7 +782,11 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
else:
logger.debug("successfully removed %s" % self.user_data_dir)
break
try:
time.sleep(0.1)
except OSError:
pass
# dereference patcher, so patcher can start cleaning up as well.
# this must come last, otherwise it will throw 'in use' errors