BOM发料对比
This commit is contained in:
@@ -143,11 +143,13 @@ def resolve_browser_path() -> str:
|
|||||||
|
|
||||||
|
|
||||||
def cleanup_debug_port(address: str) -> None:
|
def cleanup_debug_port(address: str) -> None:
|
||||||
"""按实际 DevTools 端口清理僵尸浏览器进程。"""
|
"""按实际 DevTools 端口清理僵尸浏览器进程及残留的锁文件。"""
|
||||||
if not address or ":" not in address:
|
if not address or ":" not in address:
|
||||||
return
|
return
|
||||||
|
|
||||||
debug_port = address.rsplit(":", 1)[-1]
|
debug_port = address.rsplit(":", 1)[-1]
|
||||||
|
|
||||||
|
# 1. 杀掉占用端口的僵尸进程
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
f"lsof -ti tcp:{debug_port} | xargs -r kill -9",
|
f"lsof -ti tcp:{debug_port} | xargs -r kill -9",
|
||||||
shell=True,
|
shell=True,
|
||||||
@@ -155,6 +157,15 @@ def cleanup_debug_port(address: str) -> None:
|
|||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 2. 如果在 Linux 环境,彻底清理残留的 DrissionPage 锁文件,防止 "Failed to create SingletonLock"
|
||||||
|
if is_linux_env():
|
||||||
|
subprocess.run(
|
||||||
|
"rm -rf /tmp/DrissionPage* /tmp/.org.chromium.*",
|
||||||
|
shell=True,
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def clear_drission_singletons() -> None:
|
def clear_drission_singletons() -> None:
|
||||||
"""
|
"""
|
||||||
@@ -241,6 +252,10 @@ def get_page(headless: bool = False, port: int = 9222) -> ChromiumPage:
|
|||||||
co.set_argument("--headless=new")
|
co.set_argument("--headless=new")
|
||||||
co.set_argument("--disable-gpu")
|
co.set_argument("--disable-gpu")
|
||||||
|
|
||||||
|
# 针对 Linux 环境下的 SingletonLock 僵尸进程导致 Chrome 静默崩溃的问题
|
||||||
|
if is_linux_env():
|
||||||
|
co.set_argument("--disable-features=ProcessSingleton")
|
||||||
|
|
||||||
co.set_argument("--disable-blink-features=AutomationControlled")
|
co.set_argument("--disable-blink-features=AutomationControlled")
|
||||||
co.set_argument("--no-sandbox")
|
co.set_argument("--no-sandbox")
|
||||||
co.set_argument("--disable-dev-shm-usage")
|
co.set_argument("--disable-dev-shm-usage")
|
||||||
|
|||||||
Reference in New Issue
Block a user