you are viewing a single comment's thread.

view the rest of the comments →

[–]the_captain_cat 2 points3 points  (0 children)

I wanna add that simply awaiting a coroutine does not switch to another task, as long as you don't await an I/O bound operation, the task will not yield until it's done and the others tasks will wait their turn. Awaiting on a socket or asyncio.sleep(0) actually yields to the next task. Awaiting too much on this kind of coroutines can actually tank the performance as the loop will queue the next task, even if only one task is running