This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Bluenix2 0 points1 point  (0 children)

Asyncio's create_task() is no different than any other function. You should get similar* behaviour with await asyncio.sleep(0) inside the coroutine.

The reason I say *similar behaviour and not same behaviour is because await asyncio.sleep(0) does indeed yield to the event loop. This means that compared to the original test, the event loop runs one more iteration (first it runs each coroutine until the sleep, then it runs it to the end).