Keywords and Expressions
await — Awaitable result and suspension
Obtain a result from an awaitable inside an async function. The coroutine may suspend until the awaited operation finishes, but an awaitable that is already ready can complete without yielding control to other tasks. Await does not by itself start a new thread, schedule independent work, or make synchronous blocking calls safe. A raised exception propagates at the await point unless handled. The operand must support the awaitable protocol; a plain integer or ordinary function return is not automatically awaitable.
Formal Syntax & Structure
python syntaxpython
await primaryParameters & Attributes
| Name | Type | Description |
|---|---|---|
| primary | awaitable | Coroutine, future or other supported awaitable expression. |
Return Value
object
The awaited operation’s completion value; exceptions propagate instead of returning a value.
Working Example
Example Snippetpython
import asyncio
async def price(): return 12
async def main(): amount = await price() print(amount * 3)
asyncio.run(main())