diff --git a/tasks/enduro-trails/prototype/app.py b/tasks/enduro-trails/prototype/app.py index e688be4..234bf1b 100644 --- a/tasks/enduro-trails/prototype/app.py +++ b/tasks/enduro-trails/prototype/app.py @@ -913,7 +913,7 @@ async def _build_segmented_route(req: RouteRequest) -> dict: except Exception as e: raise HTTPException(503, f"OSRM недоступен: {e}") - # Retry TooBig → 3 → 1 + # Retry TooBig → 3 → 2 → 1 if data.get("code") == "TooBig": url2 = url.replace("alternatives=5", "alternatives=3") try: @@ -922,6 +922,14 @@ async def _build_segmented_route(req: RouteRequest) -> dict: data = resp.json() except Exception as e: raise HTTPException(503, f"OSRM недоступен: {e}") + if data.get("code") == "TooBig": + url2b = url.replace("alternatives=5", "alternatives=2") + try: + async with httpx.AsyncClient(timeout=60) as client: + resp = await client.get(url2b) + data = resp.json() + except Exception as e: + raise HTTPException(503, f"OSRM недоступен: {e}") if data.get("code") == "TooBig": url1 = url.replace("alternatives=5", "alternatives=false") try: