@@ -37,25 +37,24 @@ Event Loop
3737==========
3838
3939Everything in asyncio happens relative to the event loop.
40- It's the star of the show and there's only one .
40+ It's the star of the show.
4141It's kind of like an orchestra conductor or military general.
42- She 's behind the scenes managing resources.
43- Some power is explicitly granted to her , but a lot of her ability to get things
44- done comes from the respect and cooperation of her subordinates.
42+ It 's behind the scenes managing resources.
43+ Some power is explicitly granted to it , but a lot of its ability to get things
44+ done comes from the respect and cooperation of its subordinates.
4545
4646In more technical terms, the event loop contains a queue of tasks to be run.
4747Some tasks are added directly by you, and some indirectly by asyncio.
4848The event loop pops a task from the queue and invokes it (or gives it control),
49- similar to calling a function.
50- That task then runs.
49+ similar to calling a function, then that task runs.
5150Once it pauses or completes, it returns control to the event loop.
5251The event loop will then move on to the next task in its queue and invoke it.
5352This process repeats indefinitely.
5453Even if the queue is empty, the event loop continues to cycle (somewhat aimlessly).
5554
56- Effective overall execution relies on tasks sharing well.
57- A greedy task could hog control and leave the other tasks to starve, rendering
58- the overall event loop approach rather useless.
55+ Effective execution relies on tasks sharing well: a greedy task could hog
56+ control and leave the other tasks to starve, rendering the overall event loop
57+ approach rather useless.
5958
6059::
6160
@@ -85,17 +84,19 @@ Calling a regular function invokes its logic or body::
8584 fresh paper and a loving octopus-wife.
8685 >>>
8786
88- This is an asynchronous-function or coroutine-function::
87+ The :ref: `async def <async def >`, as opposed to just a plain ``def ``, makes
88+ this an asynchronous function (or coroutine function).
89+ Calling it creates and returns a :ref: `coroutine <coroutine >` object.
90+
91+ ::
8992
9093 async def special_fella(magic_number: int):
9194 print(
9295 "I am a super special function. Far cooler than that printer. "
9396 f"By the way, my lucky number is: {magic_number}."
9497 )
9598
96- Calling an asynchronous function creates and returns a
97- :ref: `coroutine <coroutine >` object.
98- It does not execute the function::
99+ Note that calling it does not execute the function::
99100
100101 >>> special_fella(magic_number=3)
101102 <coroutine object special_fella at 0x104ed2740>
0 commit comments