All courses
· advanced

Async Python

When a program spends its time waiting rather than computing, async lets it wait for many things at once. Coroutines, the event loop, running work concurrently, and the mistakes that quietly make it sequential again.

Pathaxis · Original content

Written in house, from the work rather than from a syllabus. Every example is one we would use ourselves, and every exercise is checked against the same engine that grades your answer.

84 min 6 lessons 20 quiz questions 6 exercisesStart course

What you’ll learn

  • Tell work that waits from work that computes, and know which async helps
  • Write a coroutine with async def and await another one
  • Run many coroutines concurrently with gather or a task group
  • Cancel work and apply a timeout without leaving tasks behind
  • Spot a blocking call that stalls the entire event loop
  • Limit how many things run at once with a semaphore

Before you start

  • · Comfortable with functions, exceptions and generators
  • · Some experience calling something slow, such as an HTTP API

Syllabus

01

Why async exists

The problem it solves, and the one it does not.

02

Coroutines

Writing and running them, and making them overlap.

03

Doing it properly

Cancellation, blocking calls, and keeping concurrency under control.