Registry / http-networking / retryhttp

retryhttp

JSON →
library1.5.0pypypi✓ verified 26d ago

RetryHTTP is a Python library designed to simplify retrying potentially transient HTTP errors. It extends the `tenacity` library with custom retry and wait strategies, offering sensible defaults while remaining fully customizable. The library provides decorators to automatically retry HTTP requests in applications using `requests`, `httpx`, or `aiohttp`.

pip install retryhttp
INSTALL
IMPORT
SIG · RETRYHTTP
R
retryhttp
http-networkingpythonv1.5.0
Install
4.3s avg
Import
563ms
Disk
37MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.588s · 37MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 4.3s · import 0.538s · 38MB
37MB installed
● package 37MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

retry
from retryhttp import retry

This quickstart demonstrates how to use the `@retry` decorator with `httpx`. The decorated function will automatically retry on transient HTTP status codes (429, 500, 502, 503, 504), network errors, and timeouts, with appropriate backoff strategies. The `raise_for_status()` call is crucial to convert HTTP error responses into exceptions that `retryhttp` can intercept and retry.

import httpx from retryhttp import retry @retry def fetch_data_with_retries(): """Fetches data from example.com, retrying on transient HTTP errors.""" print("Attempting to fetch data...") try: response = httpx.get("https://example.com/") response.raise_for_status() # Raise an exception for HTTP errors (4xx or 5xx) print("Successfully fetched data!") return response.text except httpx.HTTPStatusError as e: print(f"HTTP error occurred: {e.response.status_code}") raise # Re-raise to trigger retry logic if it's a retryable status except httpx.RequestError as e: print(f"Request error occurred: {e}") raise # Re-raise to trigger retry logic on network errors/timeouts if __name__ == "__main__": data = fetch_data_with_retries() # In a real scenario, you'd process 'data' here # For this example, we just show successful fetch or final failure
Debug
Known issues
gotchaBe cautious when retrying non-idempotent HTTP methods like POST, PUT, or DELETE by default. While `retryhttp` has sensible defaults for many scenarios, blindly retrying these can lead to unintended side effects (e.g., duplicate resource creation). Always understand your API's idempotency guarantees.
fix
Carefully configure `retry` decorator parameters (`retry_exceptions`, `retry_on_exception`, `retry_codes`) or wrap non-idempotent calls with more restrictive retry policies if there's any doubt about idempotency.
affects: All versions
gotchaFor full integration and client-specific error handling, remember to install `retryhttp` with the relevant optional dependencies (e.g., `pip install retryhttp[httpx]` for HTTPX support). Without these, `retryhttp` may still catch generic exceptions but won't be able to leverage client-specific error types for more granular retry logic.
fix
Install the necessary client-specific extras: `pip install retryhttp[httpx]`, `pip install retryhttp[requests]`, or `pip install retryhttp[aiohttp]` depending on your chosen HTTP client library.
affects: All versions
gotchaIf customizing retry behavior, be aware that `retryhttp` extends `tenacity`. While it provides its own decorator, deeper customizations might involve understanding `tenacity`'s retry strategies, wait strategies, and stop conditions. Ensure your custom logic correctly integrates with `retryhttp`'s opinionated defaults.
fix
Refer to both `retryhttp`'s documentation for its provided decorators and `tenacity`'s documentation for advanced customization options when creating complex retry policies.
affects: All versions
Upgrade
Version history
1.5.0latest on PyPI · released Jun 22, 2026
Audit
Dependencies
tenacityrequiredCore dependency; retryhttp extends its functionality.
httpxoptionalEnables HTTPX integration for retries.
requestsoptionalEnables requests integration for retries.
aiohttpoptionalEnables aiohttp integration for retries.
Agent activity
7 hits · last 30 days
node
6
Resources
retryhttp — pip install retryhttp · libregistry