From e445892259b105e10470b61b56f85cfdf4c06577 Mon Sep 17 00:00:00 2001 From: Adam French Date: Tue, 8 Sep 2026 00:54:33 +0100 Subject: [PATCH] Give TfL cycle lookups a single attempt TfL can take over 15s to return 404 for destinations with no cycle route (motorway services), and retrying that three times stalled a hotel for almost a minute. The distance estimate covers the gap. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01Dphx7LL5JC8dAFYU7MMpoA --- python/app/travelodge.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/app/travelodge.py b/python/app/travelodge.py index 9f8920d..f7698b3 100644 --- a/python/app/travelodge.py +++ b/python/app/travelodge.py @@ -457,7 +457,7 @@ def cycle_time(origin, hotel, when, app_key, deadline=None, journeys=None): if not app_key: return est_min, est_km, "estimate" if journeys is None: - journeys = tfl_journeys(origin, dest, when, CYCLE_QUERY, app_key, deadline=deadline) + journeys = tfl_journeys(origin, dest, when, CYCLE_QUERY, app_key, retries=1, deadline=deadline) for j in journeys: if isinstance(j.get("duration"), int): km = sum((l.get("distance") or 0) for l in (j.get("legs") or [])) / 1000 @@ -577,11 +577,14 @@ def run_search( ThreadPoolExecutor(max_workers=TFL_HOTEL_WORKERS) as hotel_pool: def price(h): - # Kick off the cycle lookup first so it overlaps the fare lookups. + # Kick off the cycle lookup first so it overlaps the fare lookups. One + # attempt only: TfL can take 15s+ to say there is no cycle route (e.g. + # motorway services), and the distance estimate is a fine fallback. cycle_fut = None if app_key: cycle_fut = tfl_pool.submit( - tfl_journeys, origin, (h["lat"], h["lon"]), depart_dt, CYCLE_QUERY, app_key, deadline=deadline + tfl_journeys, origin, (h["lat"], h["lon"]), depart_dt, CYCLE_QUERY, app_key, + retries=1, deadline=deadline, ) t = best_transport(origin, h, depart_dt, adults, railcard_holders, max_travel_min, app_key, deadline=deadline, pool=tfl_pool)