undetected-chromedriver icon indicating copy to clipboard operation
undetected-chromedriver copied to clipboard

Warning issued on program exit after driver.quit()

Open j-foreman opened this issue 2 years ago • 1 comments

I run the following script:

import logging
import undetected_chromedriver as uc

logging.basicConfig(level=logging.DEBUG)

driver = uc.Chrome()
input("return to continue")
driver.quit()
input("return to continue")

and I get the following output (note the warnings in the last part):

DEBUG:undetected_chromedriver.patcher:getting release number from /LATEST_RELEASE
DEBUG:undetected_chromedriver.patcher:downloading from https://chromedriver.storage.googleapis.com/104.0.5112.79/chromedriver_mac64.zip
DEBUG:undetected_chromedriver.patcher:unzipping /var/folders/cv/8c_t5jd560bfz76bqmjgpk880000gn/T/tmp2hg9tzbl
INFO:undetected_chromedriver.patcher:patching driver executable /Users/velin/Library/Application Support/undetected_chromedriver/2e5bb6aae0e226f1_chromedriver
DEBUG:selenium.webdriver.remote.remote_connection:POST http://localhost:63029/session {"capabilities": {"firstMatch": [{}], "alwaysMatch": {"browserName": "chrome", "pageLoadStrategy": "normal", "goog:chromeOptions": {"extensions": [], "binary": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "args": ["--remote-debugging-host=127.0.0.1", "--remote-debugging-port=63028", "--user-data-dir=/var/folders/cv/8c_t5jd560bfz76bqmjgpk880000gn/T/tmp7xexd3qb", "--lang=en-GB", "--no-default-browser-check", "--no-first-run", "--log-level=0"], "debuggerAddress": "127.0.0.1:63028"}}}}
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): localhost:63029
DEBUG:urllib3.connectionpool:http://localhost:63029 "POST /session HTTP/1.1" 200 670
DEBUG:selenium.webdriver.remote.remote_connection:Remote response: status=200 | data={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"104.0.5112.101","chrome":{"chromedriverVersion":"104.0.5112.79 (3cf3e8c8a07d104b9e1260c910efb8f383285dc5-refs/branch-heads/5112@{#1307})"},"goog:chromeOptions":{"debuggerAddress":"127.0.0.1:63028"},"pageLoadStrategy":"normal","platformName":"","proxy":{},"setWindowRect":false,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:credBlob":true,"webauthn:extension:largeBlob":true,"webauthn:virtualAuthenticators":true},"sessionId":"7e7136c3d7fe89e3b7b6065a29aec57c"}} | headers=HTTPHeaderDict({'Content-Length': '670', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:selenium.webdriver.remote.remote_connection:Finished Request
return to continue
DEBUG:undetected_chromedriver.patcher:successfully unlinked /Users/velin/Library/Application Support/undetected_chromedriver/2e5bb6aae0e226f1_chromedriver
return to continue
DEBUG:undetected_chromedriver.dprocess:cleaning up pid 16533 
DEBUG:selenium.webdriver.remote.remote_connection:DELETE http://localhost:63029/session/7e7136c3d7fe89e3b7b6065a29aec57c {}
DEBUG:urllib3.connectionpool:Resetting dropped connection: localhost
DEBUG:urllib3.util.retry:Incremented Retry for (url='/session/7e7136c3d7fe89e3b7b6065a29aec57c'): Retry(total=2, connect=None, read=None, redirect=None, status=None)
WARNING:urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x1029b8d10>: Failed to establish a new connection: [Errno 61] Connection refused')': /session/7e7136c3d7fe89e3b7b6065a29aec57c
DEBUG:urllib3.connectionpool:Starting new HTTP connection (2): localhost:63029
DEBUG:urllib3.util.retry:Incremented Retry for (url='/session/7e7136c3d7fe89e3b7b6065a29aec57c'): Retry(total=1, connect=None, read=None, redirect=None, status=None)
WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x101f5b150>: Failed to establish a new connection: [Errno 61] Connection refused')': /session/7e7136c3d7fe89e3b7b6065a29aec57c
DEBUG:urllib3.connectionpool:Starting new HTTP connection (3): localhost:63029
DEBUG:urllib3.util.retry:Incremented Retry for (url='/session/7e7136c3d7fe89e3b7b6065a29aec57c'): Retry(total=0, connect=None, read=None, redirect=None, status=None)
WARNING:urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x1028353d0>: Failed to establish a new connection: [Errno 61] Connection refused')': /session/7e7136c3d7fe89e3b7b6065a29aec57c
DEBUG:urllib3.connectionpool:Starting new HTTP connection (4): localhost:63029

If I don't run driver.quit() and just let the program exit I don't see the warnings. This seems to happen because when the program exits the quit() method of selenium WebDriver is called here but the browser is already closed by the earlier driver.quit() method in my script.

j-foreman avatar Aug 30 '22 13:08 j-foreman

i'm having the same problem here

kthehatter avatar Sep 14 '22 20:09 kthehatter

I had the same problem and I used driver.close() instead (only).

Altimis avatar Sep 26 '22 14:09 Altimis

Quick fix, but I'm not sure if it's correct. I just overridden the del method. Correct me if I am wrong

class Chrome(uc.Chrome):

    def __del__(self):
        self.quit()

mayflowerr avatar Nov 04 '22 23:11 mayflowerr

@mayflowerr You might be onto something, please check #890 to join the discussion

sebdelsol avatar Nov 14 '22 13:11 sebdelsol