Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danlamanna/retryable-requests
Easy to use retryable requests sessions.
https://github.com/danlamanna/retryable-requests
Last synced: about 2 months ago
JSON representation
Easy to use retryable requests sessions.
- Host: GitHub
- URL: https://github.com/danlamanna/retryable-requests
- Owner: danlamanna
- License: apache-2.0
- Created: 2021-08-31T15:15:22.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-08-05T21:10:48.000Z (over 2 years ago)
- Last Synced: 2024-11-10T18:58:20.574Z (about 2 months ago)
- Language: Python
- Homepage:
- Size: 32.2 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# retryable-requests
[![PyPI](https://img.shields.io/pypi/v/retryable-requests)](https://pypi.org/project/retryable-requests/)Easy to use retryable requests sessions.
## Quickstart
### Common case
``` python
from retryable_requests import RetryableSessionwith RetryableSession() as session:
session.get('https://httpbin.org/get') # will be retried up to 5 times
```### Only retry on 429 errors
``` python
from requests.packages.urllib3.util.retry import Retry
from retryable_requests import RetryableSessionretry_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
```### Automatically use a base URL for every request
``` python
from retryable_requests import RetryableSessionwith 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)
```## Features
- Automatic backing off retries for failed requests that can be safely retried
- Quick timeouts for non-responsive requests## See also
- [urllib3.util.Retry](https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#urllib3.util.Retry)
- [requests.Session](https://docs.python-requests.org/en/master/user/advanced/#session-objects)
- [requests_toolbelt.sessions.BaseUrlSession](https://toolbelt.readthedocs.io/en/latest/sessions.html#baseurlsession)
- [Timeouts in Requests](https://docs.python-requests.org/en/master/user/advanced/#timeouts)