From 8ba1860170d31a937e9b2c08a01f733342253b62 Mon Sep 17 00:00:00 2001 From: Stream Date: Wed, 6 May 2026 19:00:01 +0300 Subject: [PATCH] auto-sync: 2026-05-06 19:00:01 --- tasks/enduro-trails/prototype/app.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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: