Skip to content

Commit

Permalink
add logging when rate limited
Browse files Browse the repository at this point in the history
  • Loading branch information
FuzzyGrim committed Mar 21, 2024
1 parent 7c51477 commit 7dfbebb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/providers/services.py
Expand Up @@ -29,7 +29,9 @@ def api_request(method, url, params=None, json=None, headers=None):
rate_limit_code = 429
if response.status_code == rate_limit_code:
seconds_to_wait = int(response.headers["Retry-After"])
logger.warning("Rate limited, waiting %s seconds", seconds_to_wait)
time.sleep(seconds_to_wait)
logger.info("Retrying request")
return api_request(method, url, params=params, json=json, headers=headers)

response.raise_for_status()
Expand Down

0 comments on commit 7dfbebb

Please sign in to comment.