In "The Python Language Reference, Release 3.13.0a0",
there is this section:
|6.4 Await expression
|
|Suspend the execution of coroutine on an awaitable object.
|Can only be used inside a coroutine function.
|
|await_expr ::= "await" primary
|
|New in version 3.5.
. And this is the whole section.
What I do not understand:
- Which coroutine is suspended?
- Which object is the object mentioned?
- For what purpose is the value of the primary expression used?
- What does it mean to "suspend something on something"?
We say that an object is an awaitable object if it can be used in an
await expression. Many asyncio APIs are designed to accept awaitables.
There are three main types of awaitable objects:
coroutines, Tasks, and Futures.
Stefan Ram schrieb:
˙˙ In "The Python Language Reference, Release 3.13.0a0",
˙˙ there is this section:
|6.4 Await expression
|
|Suspend the execution of coroutine on an awaitable object.
|Can only be used inside a coroutine function.
|
|await_expr ::= "await" primary
|
|New in version 3.5.
˙˙ . And this is the whole section.
˙˙ What I do not understand:
˙˙ - Which coroutine is suspended?
˙˙ - Which object is the object mentioned?
˙˙ - For what purpose is the value of the primary expression used?
˙˙ - What does it mean to "suspend something on something"?
You can explain a function call without saying much about the called function. >Similarly, you can explain "await <expr>" without saying much about
"<expr>".
It can be a tricky thing to get to grips with, particularly if you are >trying to understand how it works at a low level.
|await_expr ::= "await" primary
|Suspend the execution of coroutine on an awaitable object.
In "The Python Language Reference, Release 3.13.0a0",
there is this section:
|6.4 Await expression
|Suspend the execution of coroutine on an awaitable object.
|Can only be used inside a coroutine function.
|await_expr ::= "await" primary
Heck, even of the respected members of this newsgroup, IIRC, no one
mentioned "__await__". So, let's give a big shoutout to Victor!
(Then, it should also be interesting to understand how asyncio
uses "await" to implement asynchronous I/O.)
So, this is how the control is transferred to the event
loop after an "await sleep"! Initially, the control goes
to "sleep", but this transfers the control to the event loop
(until "sleep" stops waiting for its future in "await future").
Sysop: | Tetrazocine |
---|---|
Location: | Melbourne, VIC, Australia |
Users: | 6 |
Nodes: | 8 (0 / 8) |
Uptime: | 48:12:43 |
Calls: | 45 |
Files: | 21,492 |
Messages: | 63,570 |