async

mac2022-06-30  20

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()

转载于:https://www.cnblogs.com/c-x-a/p/10573002.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)