Skip to content

Commit b598162

Browse files
ENH: Improving undetected-chrome finalization
1 parent 291f7b2 commit b598162

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

botcity/web/browsers/undetected_chrome.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import atexit
12
import json
23
import os
34
import platform
@@ -8,6 +9,8 @@
89
from undetected_chromedriver.options import ChromeOptions
910
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
1011

12+
from ..util import cleanup_temp_dir
13+
1114
try:
1215
from undetected_chromedriver import Service as ChromeService # noqa: F401, F403
1316
except ImportError:
@@ -77,6 +80,7 @@ def default_options(headless=False, download_folder_path=None, user_data_dir=Non
7780
temp_dir = tempfile.TemporaryDirectory(prefix="botcity_")
7881
user_data_dir = temp_dir.name
7982
chrome_options._botcity_temp_dir = user_data_dir
83+
atexit.register(cleanup_temp_dir, temp_dir)
8084

8185
chrome_options.add_argument(f"--user-data-dir={user_data_dir}")
8286

0 commit comments

Comments
 (0)