一个轻量的重试包
Project description
一个轻量的重试包
实例代码
from zretry import retry
@retry
def fun():
a = 1 / 0
fun() # 此时会不停的尝试调用直到成功, 每次尝试间隔一秒
限制尝试次数
from zretry import retry
@retry(max_attempt_count=5) # 最多尝试调用5次, 超出5次后报错
def fun():
a = 1 / 0
fun()
参数说明
参数名 | 数据类型 | 默认值 | 描述 |
---|---|---|---|
interval | float | 1 | 每次尝试间隔时间 |
max_attempt_count | int | None | 最大尝试次数 |
result_retry_flag | any | None | 如果调用的函数不报错, 它的返回值和result_retry_flag的id是同一个id, 则重试 |
error_callback | function | None | 每次尝试错误都会回调这个函数, 它接收一个参数, 该参数表示尝试的是哪个函数 |
更新日志
发布时间 | 发布版本 | 发布说明 |
---|---|---|
19-01-13 | 0.1.1 | 修复对类函数使用装饰器会导致调用时报错的bug |
19-01-08 | 0.1.0 | 发布第一版 |
本项目仅供所有人学习交流使用, 禁止用于商业用途
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
zretry-0.1.1-py3-none-any.whl
(15.2 kB
view hashes)