Asyncio Evolved: Enhanced Exception Handling with Python 3.11 TaskGroups

Junya Fukuda

Junya Fukuda

Develops "LOVOT", a family-like robot that promotes the ability to love, at GROOVE X, Inc. He has spoken at PyCon JP, DjangoCongress JP, EuroPython, and other events. As a community activity, he participates in the management of GeekLab Nagano. Co-author of "Python Practical Recipes (2022 Gijutsu Hyoron Co., Ltd.)". Translation of "Expert Python Programming - Fourth Edition". Likes beer, camping, and asyncio.

    Abstract

    With the release of Python 3.11 in October 2022, PEP 654 "Exception Groups and except" was accepted, and asyncio.TaskGroup() was added. This enhancement of exception and cancellation handling has allowed asyncio to evolve more flexibly, addressing the existing issues with asyncio APIs, such as insufficient cancellation and exception handling in asyncio.gather. In this talk, I would like to discuss the problems of existing asyncio APIs and how the newly introduced asyncio.TaskGroup() solves these issues. Attendees will learn about the improved way of handling exceptions and cancellations using asyncio.TaskGroup(), enabling them to write more efficient and robust asynchronous code with Python 3.11.

    Description

    Location

    R0

    Date

    Day 1 • 13:05-13:35 (GMT+8)

    Language

    English talk

    Level

    Intermediate

    Category

    Best Practices & Patterns