BOM发料对比
This commit is contained in:
@@ -250,6 +250,9 @@ def get_page(headless: bool = False, port: int = 9222) -> ChromiumPage:
|
|||||||
|
|
||||||
if is_docker:
|
if is_docker:
|
||||||
clear_drission_singletons()
|
clear_drission_singletons()
|
||||||
|
# 暴力清理所有残留的 Chrome 进程和 Drission 临时文件,防止 Zombie Chrome 干扰 auto_port
|
||||||
|
subprocess.run("pkill -9 -f chrome || true", shell=True, stderr=subprocess.DEVNULL)
|
||||||
|
subprocess.run("rm -rf /tmp/DrissionPage*", shell=True, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
if effective_headless:
|
if effective_headless:
|
||||||
co.set_argument("--headless=new")
|
co.set_argument("--headless=new")
|
||||||
@@ -326,12 +329,27 @@ def get_page(headless: bool = False, port: int = 9222) -> ChromiumPage:
|
|||||||
log("ERR", f"[DEBUG] Page WS 降级连接失败: {ws_only_e}")
|
log("ERR", f"[DEBUG] Page WS 降级连接失败: {ws_only_e}")
|
||||||
e = ws_only_e
|
e = ws_only_e
|
||||||
|
|
||||||
log("WARN", f"[DEBUG] 尝试清理地址 {actual_address} 后重试...")
|
log("WARN", f"[DEBUG] 尝试清理并完全重启浏览器...")
|
||||||
try:
|
try:
|
||||||
clear_drission_singletons()
|
clear_drission_singletons()
|
||||||
cleanup_debug_port(actual_address)
|
cleanup_debug_port(actual_address)
|
||||||
|
subprocess.run("pkill -9 -f chrome || true", shell=True, stderr=subprocess.DEVNULL)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
page = ChromiumPage(opt)
|
# 不复用 opt,防止残留上次的 ws_address
|
||||||
|
# 重新调用自己,但要注意避免无限递归,这里简单返回一个新创建的即可
|
||||||
|
# 为了简单,我们可以直接用一个新的 opt 配置
|
||||||
|
new_co = ChromiumOptions()
|
||||||
|
new_co.set_argument("--headless=new")
|
||||||
|
new_co.set_argument("--disable-gpu")
|
||||||
|
new_co.set_argument("--no-sandbox")
|
||||||
|
new_co.set_argument("--disable-dev-shm-usage")
|
||||||
|
new_co.set_argument("--remote-allow-origins=*")
|
||||||
|
new_co.set_argument("--remote-debugging-address=127.0.0.1")
|
||||||
|
new_co.auto_port(True)
|
||||||
|
if browser_path:
|
||||||
|
new_co.set_browser_path(browser_path)
|
||||||
|
|
||||||
|
page = ChromiumPage(new_co)
|
||||||
log("OK", "[DEBUG] 清理后重试成功!")
|
log("OK", "[DEBUG] 清理后重试成功!")
|
||||||
return page
|
return page
|
||||||
except Exception as retry_e:
|
except Exception as retry_e:
|
||||||
|
|||||||
Reference in New Issue
Block a user