Skip to main content

cmdp

Retry a flaky call with exponential backoff, without hand-rolling another while loop.

Install

pip install cmdp

Usage

from cmdp import retry

@retry(n_attempts=5, n_delay=0.2, n_factor=2.0)
def fetch(url):
    return http_get(url)

@retry
def quick():
    ...

retry(lambda: do_thing(), n_attempts=2)

Behaviour

Option Default Meaning
n_attempts 3 total calls, including the first
n_delay 0.5 initial wait, seconds
n_max_delay 30.0 ceiling for the wait
n_factor 2.0 multiplier per attempt
n_exceptions (Exception,) which errors are retried

Every retry logs a warning with the attempt number and the next delay, and the final failure logs at error before re-raising the original exception.

Narrow n_exceptions in production: retrying a ValueError just wastes time.

License

MIT

Metadata

Release files for cmdp 0.0.2

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

Source distribution (sdist)

Source distribution for cmdp 0.0.2
File Size Uploaded Provenance Actions
cmdp-0.0.2.tar.gz 3.4 kB Without provenance Details for cmdp-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cmdp 0.0.2
File Interpreter ABI Platform Actions
cmdp-0.0.2-py3-none-any.whl Python 3 none any Details for cmdp-0.0.2-py3-none-any.whl

Total release size: 7.1 kB

Release files / cmdp-0.0.2.tar.gz

Download URL cmdp-0.0.2.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f0b13ce6c5164c12edea56bc93b23a4dc9a8ea013b2e871ef8a3f369af643ba9
BLAKE2b-256 checksum
How to use checksums
850f05680ed0b03724d704520420b9e4cbd3744bf2d2cdf35756ece9eec29422
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / cmdp-0.0.2-py3-none-any.whl

Download URL cmdp-0.0.2-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa3b755a995ce4bb21056ad3898183a42b9de63a3f4717b2f363fac54d53f5b2
BLAKE2b-256 checksum
How to use checksums
1d39824fc1be10d6bc294ba8908017ccdb239d25ea536b73dc2f98074311406c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for cmdp 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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