async_retrying

from async_retrying import retry
import aiohttp
import asyncio @retry(attempts=6)
async def fetch():
print(1)
async with aiohttp.ClientSession() as session:
async with session.get("https://wwww.baidu.com", verify_ssl=False) as req:
source = await req.text()
1 / 0
return source async def main():
res = await fetch()
return res if __name__ == '__main__':
loop = asyncio.get_event_loop()
try:
res = loop.run_until_complete(main())
print(res)
finally:
loop.close()
上一篇:JSP第四篇【EL表达式介绍、获取各类数据、11个内置对象、执行运算、回显数据、自定义函数、fn方法库】


下一篇:vue项目中使用mockjs+axios模拟后台数据返回