undetected-chromedriver
undetected-chromedriver copied to clipboard
Chromium is not closed when calling "driver.quit()"
Hi everybody, I has this problem with the newest version of uc:
This image is my option for creating the driver (That browser path is of chromium 114, since my current chrome version is 116)
After executing script, my is closed but I still see chromium active in task manager, and also used a lot of resouces (high cpu usage)
I have called driver.quit() at the end but it seem not work in this case. Can anyone help me this my problem ?
After the last updates with chrome 116 the chrome instances do not close correctly, you can try with
subprocess.run(["taskkill", "/F", "/IM", "chrome.exe"], check=True)
This command is working for me with no problems and avoids cpu and ram saturation.
After the last updates with chrome 116 the chrome instances do not close correctly, you can try with
subprocess.run(["taskkill", "/F", "/IM", "chrome.exe"], check=True)
This command is working for me with no problems and avoids cpu and ram saturation.
Thank you very much, it also worked for me
So this is a problem with chrome 116? The proposed solution here isn't viable for me because sometimes I have multiple scripts running at once. If I use subprocess to kill chrome, I'd kill all my scripts.
I'm not quite sure which one of these arguments solves this issue, but this doesn't occur when launched with these:
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-renderer-backgrounding")
options.add_argument("--disable-background-timer-throttling")
options.add_argument("--disable-backgrounding-occluded-windows")
options.add_argument("--disable-client-side-phishing-detection")
options.add_argument("--disable-crash-reporter")
options.add_argument("--disable-oopr-debug-crash-dump")
options.add_argument("--no-crash-upload")
options.add_argument("--disable-gpu")
options.add_argument("--disable-extensions")
options.add_argument("--disable-low-res-tiling")
options.add_argument("--log-level=3")
options.add_argument("--silent")
@trestlesky @2uanDM
So this is a problem with chrome 116? The proposed solution here isn't viable for me because sometimes I have multiple scripts running at once. If I use subprocess to kill chrome, I'd kill all my scripts.
I'm using chromium browser 114 and it can not always quit the chromium process when I called "driver.quit()". Since my script just running one process so that solution is just temporary
I'm not quite sure which one of these arguments solves this issue, but this doesn't occur when launched with these:
options.add_argument("--no-sandbox") options.add_argument("--disable-dev-shm-usage") options.add_argument("--disable-renderer-backgrounding") options.add_argument("--disable-background-timer-throttling") options.add_argument("--disable-backgrounding-occluded-windows") options.add_argument("--disable-client-side-phishing-detection") options.add_argument("--disable-crash-reporter") options.add_argument("--disable-oopr-debug-crash-dump") options.add_argument("--no-crash-upload") options.add_argument("--disable-gpu") options.add_argument("--disable-extensions") options.add_argument("--disable-low-res-tiling") options.add_argument("--log-level=3") options.add_argument("--silent")
@trestlesky @2uanDM
Thank you @trestlesky, let's me try this
I'm not quite sure which one of these arguments solves this issue, but this doesn't occur when launched with these:
options.add_argument("--no-sandbox") options.add_argument("--disable-dev-shm-usage") options.add_argument("--disable-renderer-backgrounding") options.add_argument("--disable-background-timer-throttling") options.add_argument("--disable-backgrounding-occluded-windows") options.add_argument("--disable-client-side-phishing-detection") options.add_argument("--disable-crash-reporter") options.add_argument("--disable-oopr-debug-crash-dump") options.add_argument("--no-crash-upload") options.add_argument("--disable-gpu") options.add_argument("--disable-extensions") options.add_argument("--disable-low-res-tiling") options.add_argument("--log-level=3") options.add_argument("--silent")
@trestlesky @2uanDM
Thank you @trestlesky, let's me try this
This does seem to be working for now, though I tried playing around with the different options, and like you I have no idea which options did the trick.
Unset the --no-sandbox
Chrome argument, setting no_sandbox
argument of uc.Chrome
to False
, because it is set to True
by default. Example:
uc.Chrome(driver_executable_path=driver_executable_path, options=options, user_data_dir=user_data_dir, no_sandbox=False, user_multi_procs=True, use_subprocess=False)
But some things to consider:
Users say that undetected-chromedriver doesn't work without --no-sandbox
Chrome argument on Windows 7 and lower, but works on Windows 8.1 and above. I didn't tested that for myself, but I think it's true.
Also, undetected-chromedriver most of the times doesn't work on Linux without --no-sandbox
Chrome argument(when running test script as root user for example). So, that's because no_sandbox
argument of uc.Chrome
is set to True
by default. Concluding that, set no_sandbox
argument of uc.Chrome
to False
for Windows, and set to True
for Linux.
But I warn that undetected-chromedriver has breached no_sandbox
functionality, so --no-sandbox
is always set, whether or not you set it to True
or False
. I've made pull request to fix it, so we need to wait until it is applied(or download my fork, and use as custom Python module). https://github.com/ultrafunkamsterdam/undetected-chromedriver/pull/1542
Unset the
--no-sandbox
Chrome argument, settingno_sandbox
argument ofuc.Chrome
toFalse
, because it is set toTrue
by default. Example:uc.Chrome(driver_executable_path=driver_executable_path, options=options, user_data_dir=user_data_dir, no_sandbox=False, user_multi_procs=True, use_subprocess=False)
But some things to consider: Users say that undetected-chromedriver doesn't work without
--no-sandbox
Chrome argument on Windows 7 and lower, but works on Windows 8.1 and above. I didn't tested that for myself, but I think it's true. Also, undetected-chromedriver most of the times doesn't work on Linux without--no-sandbox
Chrome argument(when running test script as root user for example). So, that's becauseno_sandbox
argument ofuc.Chrome
is set toTrue
by default. Concluding that, setno_sandbox
argument ofuc.Chrome
toFalse
for Windows, and set toTrue
for Linux. But I warn that undetected-chromedriver has breachedno_sandbox
functionality, so--no-sandbox
is always set, whether or not you set it toTrue
orFalse
. I've made pull request to fix it, so we need to wait until it is applied(or download my fork, and use as custom Python module). #1542
is worked!
@dangsonwheredidyoufindthis
I tested it and disable gpu is that one argument. No idea why its that tho
options.add_argument("--disable-gpu")
The only way I fixed this issue was calling close()
before quit()
like:
driver.close()
driver.quit()