From a69a7e2ca77cae7991e520c26e51aaac9522bf7b Mon Sep 17 00:00:00 2001 From: 11AnJo <63150129+11AnJo@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:54:41 +0100 Subject: [PATCH] Update __init__.py Prevents annoying error while using with seleniumwire. `Exception ignored in: Traceback (most recent call last): File "C:\Users\dupa\miniconda3\envs\snap\Lib\site-packages\undetected_chromedriver\__init__.py", line 824, in __del__ File "C:\Users\dupa\miniconda3\envs\snap\Lib\site-packages\seleniumwire\webdriver.py", line 69, in quit File "C:\Users\dupa\miniconda3\envs\snap\Lib\site-packages\undetected_chromedriver\__init__.py", line 811, in quit OSError: [WinError 6] The handle is invalid` Seleniumwire is already calling quit() then it goes to __del__ and its trying to close again already closed process. --- undetected_chromedriver/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/undetected_chromedriver/__init__.py b/undetected_chromedriver/__init__.py index 2d78589..ac3af14 100644 --- a/undetected_chromedriver/__init__.py +++ b/undetected_chromedriver/__init__.py @@ -840,7 +840,11 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver): self.service.process.kill() except: # noqa pass - self.quit() + + try: + self.quit() + except OSError: + pass @classmethod def _ensure_close(cls, self):