awaitEasy Examples

Pauses execution of an async coroutine until a result is available

Awaiting coroutines

Using await to get results from async operations.

python
import asyncio

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

async def get_string():
    await asyncio.sleep(0)
    return "hello"

async def main():
    # await pauses until the coroutine completes
    num = await get_number()
    text = await get_string()
    print(f"Number: {num}")
    print(f"String: {text}")

asyncio.run(main())
Expected Output
Number: 42
String: hello

await pauses the current coroutine until the awaited one completes, then returns its result. You can only use await inside async functions.

Want to try these examples interactively?

Open Easy Playground