Skip to main content

一个轻量的重试包

实例代码

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 发布第一版

本项目仅供所有人学习交流使用, 禁止用于商业用途

Metadata

Release files for zretry 0.1.1

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

Built distribution (wheel)

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

Release files / zretry-0.1.1-py3-none-any.whl

Download URL zretry-0.1.1-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2fd49d63c69deb23f05cef3544da9fa02b293bdccd40eb24c59292a4bfd8cf8
BLAKE2b-256 checksum
How to use checksums
0323cf5db00ef45a37cf6dfe00dca6ef6ce8acc8930eb0c604468e267eaa4068
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.5

Security for zretry 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

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