Skip to content

Commit

Permalink
Fix retry header
Browse files Browse the repository at this point in the history
  • Loading branch information
betterengineering committed Jan 17, 2025
1 parent 10449c1 commit b81d4b0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions utils/onboarding/backend_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def _make_request(
return r.json()

if r.status_code == 429:
retry_after = _parse_retry_after(r.headers.get("Retry-After"))
retry_after = _parse_retry_after(r.headers.get("X-RateLimit-Reset"))
logger.info(f" Received 429, retrying in: [{retry_after}]")
if retry_after > 0:
retry_delay = max(retry_after, retry_delay)
retry_delay += random.uniform(0, 1)
Expand All @@ -69,9 +70,12 @@ def _make_request(


def _parse_retry_after(retry_after):
if retry_after is None:
return -1

try:
return int(retry_after)
except ValueError:
except (ValueError, TypeError):
return -1


Expand Down

0 comments on commit b81d4b0

Please sign in to comment.