【文件属性】:
文件名称:retry_on_exceptions:用于通过捕获指定的异常之一然后重试来重试函数 N 次的装饰器
文件大小:4KB
文件格式:ZIP
更新时间:2021-06-12 01:13:06
Python
retry_on_exceptions 装饰器
用于通过捕获指定的异常之一然后重试来重试函数 N 次的装饰器。 对于偶尔抛出错误的函数特别有用,例如依赖外部资源(如 Web API、数据库等)的函数。
安装:
pip install retry_on_exceptions
或通过源代码:
git clone git://github.com/fjsj/retry_on_exceptions.git
cd retry_on_exceptions
python setup.py install
用法:
from retry import retry_on_exceptions
current_try = 0
@retry_on_exceptions(types=[ZeroDivisionError, KeyError], tries=3)
def test():
glob
【文件预览】:
retry_on_exceptions-master
----setup.py(969B)
----.gitignore(12B)
----retry()
--------__init__.py(1KB)
--------test.py(2KB)
----MANIFEST.in(33B)
----LICENSE(1KB)
----README.md(1KB)