When you call asyncio.create_task(coro)
, the coroutine doesn’t just get registered. It is scheduled immediately on the event loop. That means the coroutine is started right away, up until its first await
.
That’s why you see Do something with 1...
printed immediately after creating task1
: the event loop gives it a chance to run at least until it hits await asyncio.sleep(...)
. Same for task2
.