Skip to content

Commit

Permalink
Respect Retry-After header in 503 responses.
Browse files Browse the repository at this point in the history
These responses generally ask for a delay to clear the condition that
caused the failure (e.g., a pod or worker restart).
  • Loading branch information
kfindeisen committed Nov 19, 2024
1 parent c441071 commit 2459201
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ async def knative_request(
)

if retry and result.status_code == 503:
if 'Retry-After' in result.headers:
delay = int(result.headers['Retry-After'])
logging.info("Waiting %d seconds before retrying nextVisit %s...", delay, info)
await asyncio.sleep(delay)

logging.info(
f"retry after status code {result.status_code} for nextVisit {info}"
)
Expand Down

0 comments on commit 2459201

Please sign in to comment.