qwen1
This commit is contained in:
1 parent
030cc98448
commit
faf0f0d40e
2 files changed
+17
-14
No files matched your search
Binary file not shown.
@@ -79,6 +79,7 @@ async def run_browser_task(task_id: str, task: str, max_steps: int, model: str):
|
||||
if REMOTE_DEBUGGING_ENABLED:
|
||||
import subprocess
|
||||
import glob
|
||||
import urllib.request
|
||||
|
||||
# Точный путь из контейнера
|
||||
CHROME_PATH = "/root/.cache/ms-playwright/chromium-1208/chrome-linux64/chrome"
|
||||
@@ -114,41 +115,43 @@ async def run_browser_task(task_id: str, task: str, max_steps: int, model: str):
|
||||
"--no-first-run",
|
||||
"--no-default-browser-check",
|
||||
"--disable-extensions",
|
||||
"--disable-popup-blocking",
|
||||
"--disable-gpu",
|
||||
"--no-sandbox",
|
||||
"--disable-dev-shm-usage",
|
||||
"--disable-software-rasterizer",
|
||||
"--disable-setuid-sandbox",
|
||||
"--disable-blink-features=AutomationControlled",
|
||||
"--headless",
|
||||
"--disable-web-security",
|
||||
"about:blank"
|
||||
]
|
||||
|
||||
# Запускаем процесс
|
||||
process = subprocess.Popen(
|
||||
chrome_cmd,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE
|
||||
)
|
||||
|
||||
# Даем браузеру время запуститься и проверяем CDP
|
||||
import time
|
||||
import urllib.request
|
||||
# Ждем пока Chrome запустится и CDP будет готов
|
||||
cdp_ready = False
|
||||
for i in range(15): # Ждем до 15 секунд
|
||||
for i in range(30): # Ждем до 30 секунд
|
||||
await asyncio.sleep(1)
|
||||
try:
|
||||
response = urllib.request.urlopen(f"http://localhost:{REMOTE_DEBUGGING_PORT}/json/version", timeout=1)
|
||||
response = urllib.request.urlopen(
|
||||
f"http://localhost:{REMOTE_DEBUGGING_PORT}/json/version",
|
||||
timeout=2
|
||||
)
|
||||
if response.status == 200:
|
||||
cdp_ready = True
|
||||
break
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if not cdp_ready:
|
||||
raise RuntimeError(f"Chrome started but CDP not ready after 15s")
|
||||
# Получаем логи Chrome
|
||||
stdout, stderr = process.communicate(timeout=5)
|
||||
raise RuntimeError(
|
||||
f"Chrome started but CDP not ready after 30s.\n"
|
||||
f"STDOUT: {stdout.decode()}\n"
|
||||
f"STDERR: {stderr.decode()}"
|
||||
)
|
||||
|
||||
# Подключаемся через CDP
|
||||
cdp_url = f"http://localhost:{REMOTE_DEBUGGING_PORT}"
|
||||
|
||||
Reference in new issue
Block a user