Skip to main content

Yet another retry implementation.

Project description

retry_toolkit

PyPI - Version PyPI - Python Version Hatch project PyPI Downloads

(Yet Another) Retry implementation for python.

Do you have code that may be subjected to intermittent failures? Then you should have a retry wapper for it. This module includes a simple retry decorator (factory) you can use. Or peek inside and copy the implementation into your own project where you can make your own tweaks.

No dependencies outside of standard python libraries

Table of Contents

Features

  • wraps a function with the following behaviors..
  • configurable number of retries un case of Exception
  • configurable backoff before retrying
  • configurable which exceptions trigger a retry
  • raises specialized 'GiveUp' exception when retries exhausted
  • all configuration items accept a callable for maximum flexibility
  • all configuration is processed live on each execution for compatibility with live adjustments, experiments, feature-flag selectable changes
  • includes an async variant with all the same features

Installation

pip install retry-toolkit

Examples

Defaults to 3 tries, no delays between, retry all exceptions:

from retry.simple import retry

@retry()
def foo():
    some_networking_stuff()

Customize the basic behaviors like so:

from retry.simple import retry

@retry(tries=4, backoff=1, exceptions=SomeConnectionError)
def foo():
    some_other_networking_stuff()

The arguments can take callables for more customization.

License

retry-toolkit is distributed under the terms of the MIT license.

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

retry_toolkit-0.6.1.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

retry_toolkit-0.6.1-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file retry_toolkit-0.6.1.tar.gz.

File metadata

  • Download URL: retry_toolkit-0.6.1.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for retry_toolkit-0.6.1.tar.gz
Algorithm Hash digest
SHA256 737b1172ab1a950100e32d205083cfa1ce5edfea1874db56a885e95a04cefd1f
MD5 e25daad2a418f004dc9030fe79697313
BLAKE2b-256 64ac673beac88c0a9d6828f63a222232d43e214a241cff46d20e4c96194a1700

See more details on using hashes here.

File details

Details for the file retry_toolkit-0.6.1-py3-none-any.whl.

File metadata

File hashes

Hashes for retry_toolkit-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8473f16da9abe66e87c35edeea463ef6eac2cc5f0d14f71e7a09cd63db7800b0
MD5 49756c150afb9acb37f363ae9cb14dfd
BLAKE2b-256 09fcda6ced5efb89f787e945426eafa4f33b80f4e04fd437349c7aa56775c0e5

See more details on using hashes here.

Supported by

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