Backoff Session for requests
Project description
spoqa-requests-backoff
Backoff session for requests
Usage
resp = BackoffSession().get('https://...')
By default, BackoffSession
tries before giving up until any following condition is met:
- Tries 10 times
- Reaches 20 seconds
- Meets
requests.RequestException
- Meets HTTP client error (4xx)
Behaviors above can be customized with parameters.
BackoffSession(
exception=(RequestException, ValueError), # Give up when ValueError occurs, too.
max_tries=100, # Tries 100 times before giving up
max_time=300, # Wait until maximum 300 seconds before giving up
giveup=lambda e: e.response.text == 'You're fired!' # Give up when specific response is met
)
BackoffSession heavily depends on backoff
package.
License
spoqa-requests-backoff is distributed under the terms of MIT License.
See LICENSE for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file spoqa-requests-backoff-0.1.1.tar.gz
.
File metadata
- Download URL: spoqa-requests-backoff-0.1.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.5 CPython/3.9.2 Linux/5.10.20-1-lts
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95b20685fd750929062f46cef649d6102cf334703901424520c85ce7044a37e6 |
|
MD5 | 52bd0776209dcd2121693d6d582ba0a3 |
|
BLAKE2b-256 | 10eb99df77a805f2d84e5f990596ed4e2b7be1679646ca32d9b289657ed468db |
File details
Details for the file spoqa_requests_backoff-0.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: spoqa_requests_backoff-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.5 CPython/3.9.2 Linux/5.10.20-1-lts
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86f69fdd87af12b4aef8187783905cd74aae83dc1fa8a9531ecb16e9277fc4aa |
|
MD5 | db06ff212638947502341741c9cc2f55 |
|
BLAKE2b-256 | 963e7a386675e2c4d22b84fdb21a2af5a16266c46217229b97a7748b16309df2 |