Skip to main content

Asyncio Fundamentals

Coroutines and async/await

0:00
LearnStep 1/4

What is a Coroutine?

Coroutines: The Building Blocks

A coroutine is a special function that can pause and resume its execution. It's defined with async def:

python

The Key Difference

Calling a coroutine function doesn't execute it - it returns a coroutine object:

python
Important: Calling greet() returns a coroutine object. You must use await or asyncio.run() to actually execute it.