Skip to main content

Backoff Session for requests

Project description

spoqa-requests-backoff

MIT License PyPI

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


Download files

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

Source Distribution

spoqa-requests-backoff-0.1.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

spoqa_requests_backoff-0.1.1-py2.py3-none-any.whl (3.5 kB view details)

Uploaded Python 2 Python 3

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

Hashes for spoqa-requests-backoff-0.1.1.tar.gz
Algorithm Hash digest
SHA256 95b20685fd750929062f46cef649d6102cf334703901424520c85ce7044a37e6
MD5 52bd0776209dcd2121693d6d582ba0a3
BLAKE2b-256 10eb99df77a805f2d84e5f990596ed4e2b7be1679646ca32d9b289657ed468db

See more details on using hashes here.

File details

Details for the file spoqa_requests_backoff-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for spoqa_requests_backoff-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 86f69fdd87af12b4aef8187783905cd74aae83dc1fa8a9531ecb16e9277fc4aa
MD5 db06ff212638947502341741c9cc2f55
BLAKE2b-256 963e7a386675e2c4d22b84fdb21a2af5a16266c46217229b97a7748b16309df2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page