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:
|
if REMOTE_DEBUGGING_ENABLED:
|
||||||
import subprocess
|
import subprocess
|
||||||
import glob
|
import glob
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
# Точный путь из контейнера
|
# Точный путь из контейнера
|
||||||
CHROME_PATH = "/root/.cache/ms-playwright/chromium-1208/chrome-linux64/chrome"
|
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-first-run",
|
||||||
"--no-default-browser-check",
|
"--no-default-browser-check",
|
||||||
"--disable-extensions",
|
"--disable-extensions",
|
||||||
"--disable-popup-blocking",
|
|
||||||
"--disable-gpu",
|
"--disable-gpu",
|
||||||
"--no-sandbox",
|
"--no-sandbox",
|
||||||
"--disable-dev-shm-usage",
|
"--disable-dev-shm-usage",
|
||||||
"--disable-software-rasterizer",
|
|
||||||
"--disable-setuid-sandbox",
|
|
||||||
"--disable-blink-features=AutomationControlled",
|
|
||||||
"--headless",
|
"--headless",
|
||||||
"--disable-web-security",
|
|
||||||
"about:blank"
|
"about:blank"
|
||||||
]
|
]
|
||||||
|
|
||||||
# Запускаем процесс
|
# Запускаем процесс
|
||||||
process = subprocess.Popen(
|
process = subprocess.Popen(
|
||||||
chrome_cmd,
|
chrome_cmd,
|
||||||
stdout=subprocess.DEVNULL,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.DEVNULL
|
stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Даем браузеру время запуститься и проверяем CDP
|
# Ждем пока Chrome запустится и CDP будет готов
|
||||||
import time
|
|
||||||
import urllib.request
|
|
||||||
cdp_ready = False
|
cdp_ready = False
|
||||||
for i in range(15): # Ждем до 15 секунд
|
for i in range(30): # Ждем до 30 секунд
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
try:
|
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:
|
if response.status == 200:
|
||||||
cdp_ready = True
|
cdp_ready = True
|
||||||
break
|
break
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not cdp_ready:
|
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
|
||||||
cdp_url = f"http://localhost:{REMOTE_DEBUGGING_PORT}"
|
cdp_url = f"http://localhost:{REMOTE_DEBUGGING_PORT}"
|
||||||
|
|||||||
Reference in new issue
Block a user