HTTPX Retry - Middleware for implementing retry policies with HTTPX
Retries are defined at the transport layer.
import httpx
from httpx_retry import RetryTransport, RetryPolicy
exponential_retry = (
RetryPolicy()
.with_attempts(3)
.with_min_delay(100)
.with_multiplier(2)
.with_retry_on(lambda code: code >= 500)
)
client = httpx.Client(transport=RetryTransport(policy=exponential_retry))
res = client.get("https://example.com")
There are examples of implementing common retry policies in /tests
- Adaptive Retry
- Circuit Breaker
- Exponential Backoff
- Fibonacci Backoff
- Fixed Delay
- Immediate Retry
- Jitter
- Linear Backoff
Available in PyPI
pip install httpx-retry
See LICENSE for more info.
See CONTRIBUTING.md for info on PRs, issues, and feature requests.
See CHANGELOG.md for summarized notes on changes or view releases for more details information on changes.