猿问

asyncio.await失败,并出现TypeError:无法解包不可迭代的协程对象

我有以下代码:


done, pending = asyncio.wait(

    [a, b],

    return_when=asyncio.FIRST_COMPLETED)

但是失败了:


Traceback (most recent call last):

  ...

  File "/.../api.py", line 83, in websockets_handler

    return_when=asyncio.FIRST_COMPLETED)

TypeError: cannot unpack non-iterable coroutine object


慕无忌1623718
浏览 276回答 1
1回答

FFIVE

好吧,应该await在asyncio.wait:)前面done, pending = await asyncio.wait(    [a, b],    return_when=asyncio.FIRST_COMPLETED)
随时随地看视频慕课网APP

相关分类

Python
我要回答