Easy to use retryable requests sessions.
from retryable_requests import RetryableSession
with RetryableSession() as session:
session.get('https://httpbin.org/get') # will be retried up to 5 times
from requests.packages.urllib3.util.retry import Retry
from retryable_requests import RetryableSession
retry_strategy = Retry(
total=5,
status_forcelist=[429],
backoff_factor=0.1,
)
with RetryableSession(retry_strategy=retry_strategy) as session:
session.get('https://httpbin.org/get') # will be retried up to 5 times, only for 429 errors
from retryable_requests import RetryableSession
with RetryableSession('https://httpbin.org/') as session:
session.get('get') # 'https://httpbin.org/get' will be retried up to 5 times
session.post('post') # 'https://httpbin.org/post' won't be retried (POST request)
- Automatic backing off retries for failed requests that can be safely retried
- Quick timeouts for non-responsive requests