Brussels / 4 & 5 February 2023


The future of Python's asyncio, an introduction to task groups, exception groups and cancellation

About structured concurrency, cancellation and what's new in Python 3.11

Python's asyncio module for concurrency evolved quite a bit in the past few years. Thanks to input from projects like Trio and Anyio, we now have constructs in Python 3.11 that allow us to adopt "structured concurrency" in Python. This is an approach to concurrency that leads to applications that are less prone to bugs, but also much easier to understand.

During this presentation, we'll have a look at the principles behind structured concurrency and how to use them. We'll have a look at task groups, exception groups and finally will be diving deep into the importance of understanding cancellation.

This will be an exciting tour in the world of concurrency where hopefully everyone learns something new.

The presentation is for anyone who's familiar with at least basic Python constructs and has also at least some understanding of concurrency (either multithreading or asyncio). Previous asyncio experience is helpful, but not needed. Experienced asyncio users will probably also find it interesting.

The presentation comes from two point of views:

  1. The importance of structured concurrency. The idea that functions should not spawn tasks/threads that can outlive the function call for multiple reasons (hard to reason about, issues with exception handling, resource leaking, etc...). This is an idea that is not unique to asyncio, but also applies to multithreading/multiprocessing.

  2. The importance of cancellation as a way of terminating anything. Cancellation is the one feature that threads don't offer, but asyncio does. (A thread can't be killed), and this is what allows us to use many concurrency constructs (timeout, termination, racing of different tasks, ...) that are not available with multithreading.


Photo of Jonathan Slenders Jonathan Slenders