Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Python · Const

await

await suspends a coroutine until an awaitable completes, then yields that awaitable’s result. It is valid only inside a coroutine function.

How it works

Inside a coroutine function, await pauses that coroutine until an awaitable completes and produces a result. The operand follows the primary-expression form, so await can be applied to coroutine objects and other awaitables such as tasks or futures.

Syntax

await primary

Parameters

NameTypeDescription
primaryawaitable expressionThe primary expression producing the awaitable to suspend on.

Returns

The result produced by the awaited object after the coroutine resumes.

Key points

  • await pauses the currently executing coroutine while the operand progresses.
  • The expression is restricted to coroutine functions rather than ordinary synchronous functions.
  • Its grammar is the keyword await followed by a primary expression.
  • An await inside an asynchronous comprehension can suspend its enclosing coroutine.
  • Asynchronous-generator methods return objects that can subsequently be awaited.

Common mistakes

  • Using await outside an async def coroutine function is invalid.
  • The operand must be awaitable; an ordinary non-awaitable value cannot be awaited.

Example: Await a coroutine

import asyncio

async def get_value():
    await asyncio.sleep(0)
    return 42

async def main():
    value = await get_value()
    print(value)

asyncio.run(main())

The coroutine pauses at await until get_value finishes, then continues with its returned value.

When to use it

Asynchronous I/O

Pause an async operation until its result is available without blocking the surrounding event loop.

Coroutine composition

Sequence dependent coroutine operations while preserving readable control flow.

Async iteration workflows

Consume results from asynchronous generators or their methods.

Interview questions

QWhat does await do?

await suspends the current coroutine on an awaitable and resumes it when that awaitable completes. The expression evaluates to the value produced by the awaitable.

Follow-up: What is the grammar for await? It is await followed by a primary expression: await primary.

QWhere may await be used?

await can appear only inside a coroutine function, normally one declared with async def. It is not a general-purpose blocking operator for synchronous functions.

Follow-up: How can synchronous code enter an async workflow? Run the top-level coroutine with an event-loop entry point such as asyncio.run.

QWhat kinds of objects can be awaited?

An awaitable is an object usable in an await expression. Common awaitables include coroutine objects, tasks, and futures.

Follow-up: What determines whether a custom object is awaitable? Its await protocol, exposed through __await__, determines how awaiting proceeds.

  • async def
  • async for
  • asyncio
  • coroutine function
  • awaitable
  • Task
  • Future
  • __await__

Source: 6. Expressions — Python 3.15.0 documentation. Checked 2026-10-16.