Skip to main content

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.

Release files for retry-toolkit 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for retry-toolkit 0.6.1
File Size Uploaded
retry_toolkit-0.6.1.tar.gz 13.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for retry-toolkit 0.6.1
File Interpreter ABI Platform
retry_toolkit-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.8 kB

Release files / retry_toolkit-0.6.1.tar.gz

Download URL retry_toolkit-0.6.1.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
737b1172ab1a950100e32d205083cfa1ce5edfea1874db56a885e95a04cefd1f
BLAKE2b-256 checksum
How to use checksums
64ac673beac88c0a9d6828f63a222232d43e214a241cff46d20e4c96194a1700
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Release files / retry_toolkit-0.6.1-py3-none-any.whl

Download URL retry_toolkit-0.6.1-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8473f16da9abe66e87c35edeea463ef6eac2cc5f0d14f71e7a09cd63db7800b0
BLAKE2b-256 checksum
How to use checksums
09fcda6ced5efb89f787e945426eafa4f33b80f4e04fd437349c7aa56775c0e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page