diff --git a/ergast_service.py b/ergast_service.py index d579f0e..8a1d861 100644 --- a/ergast_service.py +++ b/ergast_service.py @@ -35,6 +35,7 @@ class ErgastService: RETRIES = 3 # a throttled request (429) is asked again after a pause, at most this often OPEN_SEASON_TTL = 6 * 3600 # a season not yet over is asked again after six hours FAILED_BACKOFF = 600 # after a failed ask, a season is not asked again for ten minutes + REQUEST_TIMEOUT = 30 # Jolpica answers a season it has not served lately in over 10 s (13.5 s seen) # Country name normalization: Jolpica country → our country slug country_map = { @@ -111,7 +112,7 @@ class ErgastService: time.sleep(wait) self._last_request = time.monotonic() try: - with urllib.request.urlopen(url, timeout=10) as resp: + with urllib.request.urlopen(url, timeout=self.REQUEST_TIMEOUT) as resp: return json.loads(resp.read())['MRData']['RaceTable']['Races'] except urllib.error.HTTPError as e: if e.code != 429 or attempt == self.RETRIES: