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

Mes*_*ssa 6 python python-asyncio

我有这个代码:

done, pending = asyncio.wait(
    [a, b],
    return_when=asyncio.FIRST_COMPLETED)
Run Code Online (Sandbox Code Playgroud)

但它失败了:

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
Run Code Online (Sandbox Code Playgroud)

Mes*_*ssa 13

嗯,await前面应该有asyncio.wait:)

done, pending = await asyncio.wait(
    [a, b],
    return_when=asyncio.FIRST_COMPLETED)
Run Code Online (Sandbox Code Playgroud)