asyncio.wait在第一个异常时未返回
创始人
2024-09-21 06:00:53
0

使用 asyncio.gather 代替 asyncio.wait,并加入参数 return_exceptions=True,即可在第一个异常时立即返回所有结果。

示例代码:

import asyncio

async def foo(): raise Exception('foo error')

async def bar(): await asyncio.sleep(1) raise Exception('bar error')

async def main(): tasks = [foo(), bar()] try: results = await asyncio.gather(*tasks, return_exceptions=True) except Exception as e: print(f'Caught an exception: {e}') return

print(results)

if name == 'main': asyncio.run(main())

相关内容

热门资讯

透视工具!wepoker辅助工... 透视工具!wepoker辅助工具,wepoker怎么买辅助,我来教教你(一直有挂);(需添加指定Q群...
透视透视!hhpoker透视下... 透视透视!hhpoker透视下载链接在哪里,wepoker底牌透视脚本,黑科技教程(真是是有挂);免...
透视插件!hhpoker透视脚... 透视插件!hhpoker透视脚本安卓,hhpoker哪个俱乐部靠谱,软件教程(竟然有挂);wpk透视...
透视插件!aapoker脚本怎... 透视插件!aapoker脚本怎么用,哈糖大菠萝有挂吗5个常用方法,详细教程(先前真的有挂);玩家必备...
透视黑科技!wpk脚本是什么,... 透视黑科技!wpk脚本是什么,aapoker辅助软件合法吗,总结教程(一贯存在有挂);科技安装教程;...
透视安卓版!智星菠萝辅助怎么买... 透视安卓版!智星菠萝辅助怎么买,we poker辅助器下载,透视教程(原先存在有挂);一、智星菠萝辅...
透视透视!德普之星透视辅助软件... 透视透视!德普之星透视辅助软件下载,hh poker透视器下载,力荐教程(最初真的有挂);亲们利用一...
透视教程!hhpoker透视脚... 透视教程!hhpoker透视脚本,菠萝辅助器免费版的特点,透明挂教程(起初真的有挂)1、很好的工具软...
透视新版!aapoker辅助器... 透视新版!aapoker辅助器是真的吗,wepoker私人局辅助挂,AI教程(固有是真的有挂)准备好...
透视脚本!hhpoker透视脚... 透视脚本!hhpoker透视脚本,拱趴大菠萝万能辅助器,透明教程(原来是有挂) 科技详细教程;Q群1...