异步的简单重试
async_retrying的Python项目详细描述
info: | Simple retrying for asyncio |
---|
安装
pip install async_retrying
用法
importasynciofromasync_retryingimportretrycounter=0@retry@asyncio.coroutinedeffn():globalcountercounter+=1ifcounter==1:raiseRuntimeError@asyncio.coroutinedefmain():yield fromfn()loop=asyncio.get_event_loop()loop.run_until_complete(main())assertcounter==2loop.close()
python 3.3+是必需的