Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asyncio.await fails with TypeError: cannot unpack non-iterable coroutine object

I have this code:

done, pending = asyncio.wait(
    [a, b],
    return_when=asyncio.FIRST_COMPLETED)

But it fails:

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
like image 600
Messa Avatar asked Jul 25 '18 20:07

Messa


1 Answers

Well, there should be await in front of asyncio.wait :)

done, pending = await asyncio.wait(
    [a, b],
    return_when=asyncio.FIRST_COMPLETED)
like image 99
Messa Avatar answered Nov 10 '22 01:11

Messa