Metadata-Version: 2.5
Name: cmdp
Version: 0.0.4
Summary: 指数退避重试，不用再手写 while 循环。
Project-URL: Homepage, https://pypi.org/project/cmdp/
Author-email: lqxnjk <lqxnjk@qq.com>
License: MIT
License-File: LICENSE
Keywords: backoff,decorator,fault-tolerance,resilience,retry
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# cmdp

[English](#english) | 中文

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

## 安装

```console
pip install cmdp
```

## 用法

```python
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

---

<a id="english"></a>
## English

Retry a callable with exponential backoff and clear logging.

## Install

```console
pip install cmdp
```

## Usage

```python
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
