Skip to main content

Make requests's sessions auto-retry on failure.

Project description

Configures the passed-in requests’ Session to retry on failed requests due to connection errors, timeouts, specific HTTP response codes (5XX by default) and 30X redirections —anything that could fail.

Python 3.6+ supported.

Basic usage:

from retry_requests import retry
my_session = retry()
my_session.get("http://foo.bar")

Using your session and configurations:

from retry_requests import retry
from requests import Session
my_session = retry(Session(), retries=5, backoff_factor=0.2)
my_session.get('https://foo.bar')

Note that you have a TSession, a Session with a default timeout, and RSession, a Session with a timeout that always raise_for_status(), for your convenience.

Heavily inspired from Peterbe.com. Thank you!

Installing

Just pip install retry-requests.

Testing

Clone this project and then, at its root directory, run python setup.py test. Note that you need an active Internet connection to run the tests.

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for retry-requests, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size retry-requests-1.0.0.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page