https://github.com/mharrisb1/httpx-retry
Middleware for implementing retry policies with HTTPX
https://github.com/mharrisb1/httpx-retry
httpx retry retry-policy
Last synced: 3 months ago
JSON representation
Middleware for implementing retry policies with HTTPX
- Host: GitHub
- URL: https://github.com/mharrisb1/httpx-retry
- Owner: mharrisb1
- License: mit
- Created: 2024-12-21T17:32:31.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-23T17:59:46.000Z (about 1 year ago)
- Last Synced: 2025-11-07T02:38:38.728Z (7 months ago)
- Topics: httpx, retry, retry-policy
- Language: Python
- Homepage:
- Size: 802 KB
- Stars: 11
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
HTTPX Retry - Middleware for implementing retry policies with HTTPX
---
> [!CAUTION]
> This project is no longer maintained as of 2025-04-23. Everyone should migrate to [httpx-retries](https://github.com/will-ockmore/httpx-retries)
## Usage
Retries are defined at the transport layer.
```python
import httpx
from httpx_retry import RetryTransport, RetryPolicy
exponential_retry = (
RetryPolicy()
.with_max_retries(3)
.with_min_delay(0.1)
.with_multiplier(2)
.with_retry_on(lambda status_code: status_code >= 500)
)
client = httpx.Client(transport=RetryTransport(policy=exponential_retry))
res = client.get("https://example.com")
```
## Examples
There are examples of implementing common retry policies in [`/tests`](./tests)
- [Adaptive Retry](./tests/test_adaptive_retry.py)
- [Circuit Breaker](./tests/test_circuit_breaker.py)
- [Exponential Backoff](./tests/test_exponential_backoff.py)
- [Fibonacci Backoff](./tests/test_fibonacci_backoff.py)
- [Fixed Delay](./tests/test_fixed_delay.py)
- [Immediate Retry](./tests/test_immediate_retry.py)
- [Jitter](./tests/test_jitter.py)
- [Linear Backoff](./tests/test_linear_backoff.py)
## Installation
[](https://badge.fury.io/py/httpx-retry)
[](https://pypi.org/project/httpx-retry/)
[](https://pypi.org/project/httpx-retry/)
Available in [PyPI](https://pypi.org/project/httpx-retry)
```sh
pip install httpx-retry
```
## License
[](https://opensource.org/blog/license/mit)
See [LICENSE](https://github.com/mharrisb1/httpx-retry/blob/main/LICENSE) for more info.
## Contributing
[](https://github.com/mharrisb1/httpx-retry/issues)
[](https://pypistats.org/packages/httpx-retry)
See [CONTRIBUTING.md](https://github.com/mharrisb1/httpx-retry/blob/main/CONTRIBUTING.md) for info on PRs, issues, and feature requests.
## Changelog
See [CHANGELOG.md](https://github.com/mharrisb1/httpx-retry/blob/main/CHANGELOG.md) for summarized notes on changes or view [releases](https://github.com/mharrisb1/httpx-retry/releases) for more details information on changes.