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.4

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.4
File Size Uploaded Provenance Actions
cmdp-0.0.4.tar.gz 3.7 kB Without provenance Details for cmdp-0.0.4.tar.gz

Built distribution (wheel)

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

Total release size: 7.5 kB

Release files / cmdp-0.0.4.tar.gz

Download URL cmdp-0.0.4.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0b14f0e52006d9778be34af8c47383265cf968fed35f28135ea2388e5d0ecd29
BLAKE2b-256 checksum
How to use checksums
cb16d65bf79a504fd00d57d57f05f2839c14791933e80c468ac7cd9c6b965a7e
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.4-py3-none-any.whl

Download URL cmdp-0.0.4-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0616149fd6017f1082f0ecbc30f2db95e4cce6e395c2e7f98b334fdbe59caec
BLAKE2b-256 checksum
How to use checksums
94f1253882dcdec9454155659ef830efd3ead7eb00cae7801a6a091cae5d4492
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.4

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