Skip to main content

cmdp

English | 中文

指数退避重试,不用再手写 while 循环。

安装

pip install cmdp

用法

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():
    ...

说明

尝试次数、初始间隔、倍数、上限全部可配;只重试 n_exceptions 里列出的异常。每次重试打 warning,最终失败打 error 并原样抛出原始异常。生产上把 n_exceptions 收窄,重试 ValueError 只是浪费时间。

许可证

MIT


English

Retry a callable with exponential backoff and clear logging.

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():
    ...

Notes

Attempts, base delay, factor and ceiling are all configurable; only the exceptions listed in n_exceptions are retried. Every retry logs a warning; the final failure logs at error and re-raises the original exception.

License

MIT

Metadata

Release files for cmdp 0.0.3

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.3
File Size Uploaded Provenance Actions
cmdp-0.0.3.tar.gz 3.6 kB Without provenance Details for cmdp-0.0.3.tar.gz

Built distribution (wheel)

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

Total release size: 7.5 kB

Release files / cmdp-0.0.3.tar.gz

Download URL cmdp-0.0.3.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3902ad0afff9df4f7b2a82dd7a76285918c8c57fffec202c734e0d4c90f2de60
BLAKE2b-256 checksum
How to use checksums
0408471bfddc8fe67bab84d45dbc7ceebf1b5d4eb60bc23f5163a7476bed2885
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.3-py3-none-any.whl

Download URL cmdp-0.0.3-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffc5753a217016b896c44253713a2682ea1890e2ff5fbd26ac52c28181c7c582
BLAKE2b-256 checksum
How to use checksums
a2187e0e73722ef579e0c6932e7ca29bcfdf00b8faf81d3712de9222dab4c0ad
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.3

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