Python Async/Await Explained (Without the Jargon)

A plain-English explanation of Python’s async/await, when it actually helps, and the mistakes that make it worse than sync code

Async/await is one of the most misunderstood parts of Python (examples here were run on Python 3.13 and 3.15) — developers reach for it assuming it makes code faster, then get confused when it doesn’t (or makes things worse). Here’s what it actually does.

What async actually solves

Async doesn’t make your code run faster at doing CPU work — a for loop crunching numbers takes exactly as long whether it’s in an async def function or not. What async solves is waiting: when your code is waiting on something external (a network request, a database query, a file read), async lets your program do other useful work during that wait instead of sitting idle.

This means async helps enormously for I/O-bound workloads — a web server handling hundreds of concurrent requests, each mostly waiting on a database — and does essentially nothing for CPU-bound workloads like image processing or numerical computation.

The basic syntax

import asyncio

async def fetch_data():
    await asyncio.sleep(1)  # simulates waiting on I/O
    return "data"

async def main():
    result = await fetch_data()
    print(result)

asyncio.run(main())

async def marks a function as a coroutine — calling it doesn’t run it immediately, it creates a coroutine object that needs to be awaited (or scheduled) to actually execute. await pauses the current coroutine at that point, letting the event loop run other pending work until the awaited thing completes.

The mistake that makes async worse than sync

The single most common mistake: awaiting things one at a time when they could run concurrently.

import asyncio
import time


async def fetch(n):
    await asyncio.sleep(0.1)  # stands in for a network call
    return n


async def sequential():
    return [await fetch(1), await fetch(2), await fetch(3)]  # one after another


async def concurrent():
    return await asyncio.gather(fetch(1), fetch(2), fetch(3))  # all in flight at once


async def main():
    start = time.perf_counter()
    await sequential()
    slow = time.perf_counter() - start

    start = time.perf_counter()
    await concurrent()
    fast = time.perf_counter() - start
    print(f"sequential took {slow / fast:.1f}x as long as gather")


asyncio.run(main())

The sequential version gets you nothing over synchronous code: you’re still waiting for each call in turn, so three 0.1-second waits take about 0.3 seconds. asyncio.gather lets all three be in flight at once, so the same work takes about 0.1 seconds. Run on Python 3.13 and 3.15 with these waits, sequential took about three times as long; the exact ratio on a real workload depends on how many calls you make and how long each waits.

asyncio.TaskGroup (Python 3.11 and later) gives the same concurrency with one difference worth knowing. If one task raises, a TaskGroup cancels the others and raises an ExceptionGroup; asyncio.gather re-raises the first exception but leaves the other tasks running. In a test with a task that fails after 0.05 seconds beside one that needs 0.2 seconds, the sibling finished under gather and was cancelled under TaskGroup. For new code, TaskGroup is usually the safer default.

You can’t mix sync and async carelessly

Calling a blocking synchronous function (like a non-async database driver, or time.sleep instead of asyncio.sleep) from inside an async function blocks the entire event loop — every other coroutine waiting on that loop stalls too. This is the most common source of “async made my app slower” bug reports: one blocking call inside an async function defeats the entire point.

If you need to call blocking code from an async context, use asyncio.to_thread() to run it in a separate thread without blocking the event loop:

import asyncio
import time


async def ticker():
    for _ in range(3):
        await asyncio.sleep(0.05)


async def main():
    start = time.perf_counter()
    await asyncio.gather(ticker(), asyncio.to_thread(time.sleep, 0.3))
    print(f"to_thread: {time.perf_counter() - start:.2f}s")  # about 0.3, the ticker ran alongside

    async def block():
        time.sleep(0.3)  # blocks the whole event loop

    start = time.perf_counter()
    await asyncio.gather(ticker(), block())
    print(f"blocking call: {time.perf_counter() - start:.2f}s")  # about 0.4, the ticker had to wait


asyncio.run(main())

With to_thread the 0.15-second ticker ran alongside the 0.3-second blocking call. With the blocking call made directly inside a coroutine, the event loop stalled and the ticker could not start until it finished, so the total was longer.

Where you’ll actually use this

FastAPI, aiohttp, and most modern Python web frameworks are async-first — if you’re building APIs today, you’ll encounter async def route handlers immediately, whether or not you fully understand what they’re doing yet. HTTPX supports both sync and async clients, which is a good way to see the same code in both styles side by side.

Do you need to learn this right away?

Not for early-stage learning — get comfortable with core Python and synchronous code first. Async becomes necessary once you’re building anything that talks to external services under real concurrent load: a production API, a web scraper hitting many URLs, or a bot handling multiple simultaneous conversations. Trying to learn async and core Python fundamentals simultaneously tends to confuse both.

Frequently Asked Questions

What problem does async/await actually solve?

Async doesn’t make CPU work faster — it solves waiting. When code is waiting on something external like a network request or database query, async lets the program do other useful work during that wait instead of sitting idle.

Does async help CPU-bound code?

No, essentially nothing. Async helps enormously for I/O-bound workloads like a web server handling many concurrent requests mostly waiting on a database, but does nothing for CPU-bound work like image processing or numerical computation.

What’s the most common async mistake?

Awaiting things one at a time when they could run concurrently. Sequential awaits gain nothing over synchronous code. asyncio.gather or asyncio.TaskGroup (Python 3.11 and later) is what delivers the concurrency benefit by letting multiple requests be in flight at once. In a test with three 0.1-second waits, awaiting them one by one took about three times as long as gathering them.

Why does one blocking call ruin an async app’s performance?

Calling a blocking synchronous function from inside an async function blocks the entire event loop — every other coroutine waiting on that loop stalls too. Use asyncio.to_thread() to run blocking code without blocking the event loop.