|
1 | 1 | .. _a-conceptual-overview-of-asyncio: |
2 | 2 |
|
3 | | -******************************** |
4 | | -A Conceptual Overview of asyncio |
5 | | -******************************** |
| 3 | +*************************************** |
| 4 | +A Conceptual Overview of :mod:`asyncio` |
| 5 | +*************************************** |
6 | 6 |
|
7 | 7 | :Author: Alexander Nordin |
8 | 8 |
|
@@ -35,7 +35,7 @@ Event Loop |
35 | 35 |
|
36 | 36 | Everything in ``asyncio`` happens relative to the event loop. |
37 | 37 | It's the star of the show. |
38 | | -It's kind of like an orchestra conductor or military general. |
| 38 | +It's like an orchestra conductor. |
39 | 39 | It's behind the scenes managing resources. |
40 | 40 | Some power is explicitly granted to it, but a lot of its ability to get things |
41 | 41 | done comes from the respect and cooperation of its subordinates. |
@@ -135,7 +135,7 @@ Instead, it provides a generator object:: |
135 | 135 | >>> get_random_number() |
136 | 136 | <generator object get_random_number at 0x1048671c0> |
137 | 137 |
|
138 | | -You can "invoke" or proceed to the next ``yield`` of a generator by using the |
| 138 | +You can proceed to the next ``yield`` of a generator by using the |
139 | 139 | built-in function :func:`next`. |
140 | 140 | In other words, the generator runs, then pauses. |
141 | 141 | For example:: |
@@ -178,14 +178,14 @@ different ways:: |
178 | 178 | await task |
179 | 179 | await coroutine |
180 | 180 |
|
181 | | -Unfortunately, it actually does matter which type of object await is applied to. |
| 181 | +Unfortunately, it does matter which type of object is awaited. |
182 | 182 |
|
183 | 183 | ``await``\ ing a task will cede control from the current task or coroutine to |
184 | 184 | the event loop. |
185 | 185 | And while doing so, adds a callback to the awaited task's list of callbacks |
186 | 186 | indicating it should resume the current task/coroutine when it (the |
187 | 187 | ``await``\ ed one) finishes. |
188 | | -In other words, when that awaited task finishes, it adds the original task |
| 188 | +In other words, when that awaited task finishes, the original task is added |
189 | 189 | back to the event loops queue. |
190 | 190 |
|
191 | 191 | In practice, it's slightly more convoluted, but not by much. |
@@ -322,7 +322,7 @@ ways that control flow and values were passed. |
322 | 322 |
|
323 | 323 | The only way to yield (or effectively cede control) from a coroutine is to |
324 | 324 | ``await`` an object that ``yield``\ s in its ``__await__`` method. |
325 | | -That might sound odd to you. Frankly, it was to me too. You might be thinking: |
| 325 | +That might sound odd to you. You might be thinking: |
326 | 326 |
|
327 | 327 | 1. What about a ``yield`` directly within the coroutine? The coroutine becomes |
328 | 328 | an async generator, a different beast entirely. |
|
0 commit comments