Skip to main content

Middleware for implementing retry policies with HTTPX

Project description

RESPX

HTTPX Retry - Middleware for implementing retry policies with HTTPX


Usage

Retries are defined at the transport layer.

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

Installation

PyPI version PyPI - Python Version PyPI - Downloads

Available in PyPI

pip install httpx-retry

License

PyPI - License

See LICENSE for more info.

Contributing

Open Issues Stargazers

See CONTRIBUTING.md for info on PRs, issues, and feature requests.

Changelog

See CHANGELOG.md for summarized notes on changes or view releases for more details information on changes.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page