educative.io

Wrong information in the text?

Perhaps, this is wrong: “In the case where hello_python is the first coroutine to run, the execution of hello_world only starts after that the await asyncio.sleep(0.1) coroutine is yielded back to the event loop.”


Course: The Hacker's Guide to Scaling Python - Learn Interactively
Lesson: Using Asyncio - The Hacker's Guide to Scaling Python

Hello @Arthur_Khakimov,
This sentence as I understand it es saying that the hello world coroutine will have to wait until the sleep is finished which is correct. Because until the timer is finished, the next routine won’t execute.
Hope this helps

Hi @Omer_Ahmed ,

Aren’t these two functions supposed to be running concurrently via the event loop? I checked that on my laptop: indeed, hello_world coroutine is executed nearly the same time as hello_python, which makes sense to me. And it also takes the specified amount of time for the hello_python to finalize its execution, which also looks valid.

Please see the output with timestamps added:

hello Python! at 1666369553.73266
hello world! at 1666369553.732825
[None, None]