Skip to main content

Requests Resilient

Wrapper around the requests python library to make it resilient to network failures.

Drop-in for the requests top-level API: swap the import and requests retry themselves on transient failures, with exponential backoff, jitter, and respect for a server's Retry-After.

Getting started

Synchronous requests

import requests_resilient

r = requests_resilient.get('https://google.com')
print(r.status_code)  # int, 200
print(r.text)  # str

For connection pooling, shared headers or auth, create a session instead of using the module-level functions:

from requests_resilient import ResilientSession, RetryConfig

session = ResilientSession(retry_config=RetryConfig(max_retries=5, backoff_base=0.5))
r = session.get('https://api.example.com/v1/items')

What gets retried

By default: 5xx responses, 429 Too Many Requests, and connection/timeout errors — and only on idempotent methods (GET, HEAD, OPTIONS, PUT, DELETE). POST and PATCH are left alone unless you pass retry_on_post=True, because retrying a non-idempotent request can duplicate a side effect.

Rate limits: Retry-After

When a retryable response carries a Retry-After header, that value is used as the wait instead of the computed backoff. Both wire formats from RFC 9110 are understood — Retry-After: 120 and Retry-After: Wed, 21 Oct 2026 07:28:00 GMT — and a malformed value falls back to the normal backoff rather than raising.

The server's value is honoured exactly: no jitter, and not added to the exponential backoff. It named a time, and retrying earlier than it asked is how a client earns a hard ban.

from requests_resilient import ResilientSession, RetryConfig

# Wait up to 5 minutes when a server asks us to; beyond that, hand the response back.
session = ResilientSession(retry_config=RetryConfig(retry_after_max=300.0))

# Or ignore the header entirely and always use the configured backoff.
session = ResilientSession(retry_config=RetryConfig(respect_retry_after=False))

If a server asks for longer than retry_after_max (default 120s), the response is returned to you rather than blocking the call. Sleeping less than the server asked practically guarantees another 429, and silently blocking a library call for an hour is worse than letting you decide: the response still carries the header, so you can queue the work, fail the job, or wait.

The parser is exported if you want it on its own:

from requests_resilient import parse_retry_after

parse_retry_after('120')                              # 120.0
parse_retry_after('Wed, 21 Oct 2026 07:28:00 GMT')    # seconds from now, never negative
parse_retry_after('soon')                             # None -> no usable hint

Asynchronous requests

Removed in v0.3.0. There is no async_get. For async HTTP with retry, use httpx with tenacity, or run the synchronous call in a thread so it does not block the event loop:

import asyncio
import requests_resilient

r = await asyncio.to_thread(requests_resilient.get, 'https://google.com')

Metadata

Release files for requests-resilient 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for requests-resilient 0.3.1
File Size Uploaded Provenance Actions
requests_resilient-0.3.1.tar.gz 15.6 kB With provenance Details for requests_resilient-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for requests-resilient 0.3.1
File Interpreter ABI Platform Actions
requests_resilient-0.3.1-py3-none-any.whl Python 3 none any Details for requests_resilient-0.3.1-py3-none-any.whl

Total release size: 27.7 kB

Release files / requests_resilient-0.3.1.tar.gz

Download URL requests_resilient-0.3.1.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
88cb060aaf010d21ba2ec592f165121652c26380f0b00c92eb5b0a6dda95ebee
BLAKE2b-256 checksum
How to use checksums
c41ccbdb324216573a5033bd2bea6dd8cfc390b4b7a6e880c2ff7d66f792d7a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.

Transparency log

Release files / requests_resilient-0.3.1-py3-none-any.whl

Download URL requests_resilient-0.3.1-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33e1f78d758979c627d69ab04db7cf614521046e36e0fb81890fd4354339433e
BLAKE2b-256 checksum
How to use checksums
edf5e7673be0420bfe84c52a147c07435037db4af64100743182931c78503a97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.

Transparency log

Security for requests-resilient 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for requests_resilient-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page