Skip to content

Add retry logic with exponential backoff and jitter for rate limits a…#6

Merged
alex-omophub merged 1 commit intomainfrom
retry-on-failure
Mar 30, 2026
Merged

Add retry logic with exponential backoff and jitter for rate limits a…#6
alex-omophub merged 1 commit intomainfrom
retry-on-failure

Conversation

@alex-omophub
Copy link
Copy Markdown
Member

@alex-omophub alex-omophub commented Mar 30, 2026

…nd server errors

  • Introduced a new _calculate_retry_delay function to handle retry delays based on the Retry-After header and exponential backoff with jitter.
  • Updated SyncHTTPClient and AsyncHTTPClientImpl to utilize the new retry delay calculation for handling rate limits (429) and server errors (502, 503, 504).
  • Enhanced retry mechanism to improve resilience against temporary issues.

Summary by cubic

Add smarter retry handling for rate limits and transient server errors using exponential backoff with jitter. This improves resilience and respects server Retry-After guidance across both sync and async HTTP clients.

  • New Features
    • Added _calculate_retry_delay() that honors Retry-After (up to 60s) or falls back to exponential backoff starting at 0.5s, capped at 8s, with 25% jitter.
    • Updated SyncHTTPClient and AsyncHTTPClientImpl to retry on 429, 502, 503, and 504 using the new delay logic.
    • Centralized retry constants and removed hardcoded sleep values.

Written for commit 9bf08d1. Summary will update on new commits.

…nd server errors

- Introduced a new `_calculate_retry_delay` function to handle retry delays based on the Retry-After header and exponential backoff with jitter.
- Updated `SyncHTTPClient` and `AsyncHTTPClientImpl` to utilize the new retry delay calculation for handling rate limits (429) and server errors (502, 503, 504).
- Enhanced retry mechanism to improve resilience against temporary issues.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/omophub/_http.py 77.77% 4 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@alex-omophub alex-omophub merged commit 214f1b5 into main Mar 30, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant