fix delete old state
This commit is contained in:
@@ -165,6 +165,9 @@ class BrowserService:
|
||||
if not settings.STICKY_PROXY_HOST:
|
||||
return VisitResult(url=url, success=False, error="No proxy configured")
|
||||
|
||||
# Максимальное время одной попытки: запуск браузера + загрузка страницы + чтение + буфер
|
||||
attempt_timeout = reading_time + 150
|
||||
|
||||
for attempt in range(3):
|
||||
try:
|
||||
proxy_config, proxy_url, proxy_info = _make_sticky_proxy_config()
|
||||
@@ -185,8 +188,11 @@ class BrowserService:
|
||||
if proxy_locale:
|
||||
camoufox_kwargs["locale"] = proxy_locale
|
||||
|
||||
async with AsyncCamoufox(**camoufox_kwargs) as browser:
|
||||
result = await self._browse_page(browser, url, proxy_info, reading_time)
|
||||
async def _run_browser():
|
||||
async with AsyncCamoufox(**camoufox_kwargs) as browser:
|
||||
return await self._browse_page(browser, url, proxy_info, reading_time)
|
||||
|
||||
result = await asyncio.wait_for(_run_browser(), timeout=attempt_timeout)
|
||||
|
||||
is_proxy_dead = result.error and any(
|
||||
k in result.error for k in ("502", "Bad Gateway", "NS_ERROR_PROXY")
|
||||
@@ -204,6 +210,9 @@ class BrowserService:
|
||||
self._proxy_fail_streak = 0
|
||||
return result
|
||||
|
||||
except asyncio.TimeoutError:
|
||||
logger.warning(f"Visit attempt {attempt + 1} timed out after {attempt_timeout}s, retrying")
|
||||
|
||||
except (ValueError, InvalidIP, InvalidProxy) as e:
|
||||
logger.warning(f"Visit attempt {attempt + 1} proxy error, retrying: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user