retry_decorator
1 功能
函数可以根据以下条件重试:
执行结果是否成功 (like a status code not equaling 200)
Exceptions (like a function raising a requests.RequestException)
所有接受的异常也会在失败时引发原始异常!
函数执行失败可能是:
超过最大重试次数
达到最大超时时间
函数重试可以按特定的间隔间隔进行
2 例子
2.1 简单例子
2.2 装饰器
Send a GET
request to a URL until it returns a status code of 200!
每秒重试一次
2.3 添加超时时间
Same function as above, timeout after 10 seconds!
2.4 添加 exceptions 参数
Same function as above, timeout after 10 seconds!
Last updated