asyncio.wait says:
Passing coroutines objects to wait() directly is deprecated as it leads to confusing behavior.
and gives this as the confusing behavior:
wait()schedules coroutines as Tasks automatically and later returns those implicitly created Task objects in (done, pending) sets. Therefore the following code won’t work as expected: [I modified the code snippet below so that it runs]async def foo(): return 42 async def main(): coro = foo() done, pending = await asyncio.wait({coro}) if coro in done: # This branch will never be run! print('yay!') asyncio.run(main())
I just started learning about asyncio, so I don't fully understand. Can someone explain?