Skip to content

Conversation

kevalmahajan
Copy link
Member

@kevalmahajan kevalmahajan commented Jul 15, 2025

✨ Feature / Enhancement PR

πŸ”— Epic / Issue

Closes #456
Sub Issue of #258


πŸš€ Summary

A retry mechanism has been implemented for all outbound HTTP requests made using httpx.AsyncClient, improving resilience to transient network failures and temporary service outages.

Key Features:

  1. Automatic Retries with configurable maximum attempts
  2. Exponential Backoff with added jitter to prevent retry storms:
  3. Error-aware Retry Logic

Implementation Notes:

  1. Integrates with httpx.AsyncClient via a custom transport layer or middleware wrapper
  2. Retry logic is centralized and reusable across services or tools using the shared HTTP client

Impact:

  1. Significantly improves reliability for systems making HTTP requests to external or internal services
  2. Reduces the risk of failure from transient issues like network glitches or temporary rate limiting

πŸ§ͺ Checks

  • make lint passes
  • make test passes
  • CHANGELOG updated (if user-facing)

Copy link
Collaborator

@madhav165 madhav165 left a comment

Choose a reason for hiding this comment

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

Looks fine, only suggestion is

if response.status_code in NON_RETRYABLE_STATUS_CODES or response.is_success:
    return response

can go before the code checking for Retry-After header in retry_manager.py's request function.

Signed-off-by: Keval Mahajan <[email protected]>
@kevalmahajan
Copy link
Member Author

@madhav165 Made the recommended change. Thanks.

Copy link
Member

@crivetimihai crivetimihai left a comment

Choose a reason for hiding this comment

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

Passed make test doctest. Merging.

@crivetimihai crivetimihai merged commit 9800e3f into main Jul 15, 2025
26 checks passed
@crivetimihai crivetimihai deleted the implement_requests_retries branch July 15, 2025 14:54
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.

[Feature Request]: HTTPX Client with Smart Retry and Backoff Mechanism
3 participants