Stay Hungry,Stay Foolish!

Tenacity -- Retrying library for Python

Retrying library for Python

https://github.com/jd/tenacity

 

Please refer to the tenacity documentation for a better experience.

Tenacity is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just about anything. It originates from a fork of retrying which is sadly no longer maintained. Tenacity isn't api compatible with retrying but adds significant new functionality and fixes a number of longstanding bugs.

 

 

https://tenacity.readthedocs.io/en/latest/

复制代码
import random
from tenacity import retry

@retry
def do_something_unreliable():
    if random.randint(0, 10) > 1:
        raise IOError("Broken sauce, everything is hosed!!!111one")
    else:
        return "Awesome sauce!"

print(do_something_unreliable())
复制代码

 

posted @   lightsong  阅读(13)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
历史上的今天:
2022-09-15 JWT -- JSON WEB TOKEN
2016-09-15 开源软件选型分析标准【转载】
2016-09-15 lua unit test introduction
2016-09-15 lua coroutine for iterator
2016-09-15 lua table integer index 特性
千山鸟飞绝,万径人踪灭
点击右上角即可分享
微信分享提示