Loading topic
async/await syntax, can write coroutine functions, and can start a program with asyncio.run. It also assumes you are on Python 3.11 or newer. You will learn how asyncio.create_task turns a coroutine into concurrent work, when that work starts, and how results an4 min readasync/await, run them with asyncio.run, and read a try/finally block. You should already know that asyncio.create_task schedules a coroutine to run concurrently. Here we look at what happe5 min readasync/await, asyncio.run, and asyncio.create_task. It also assumes you understand try/finally and Python 3.11 or newer. asyncio.gather is the most common way to run several awaitables at once, and many codebases use it by default. It works well when everyt5 min readTask.cancel() does, when the cancellation takes effect, and how a task ends up in the cancelled state. It assumes you can create tasks with asyncio.create_task and read try/finally. Writing cleanup code for cancellation is the next chapter's topic. Here the focus is 5 min readasyncio.create_task, Task.cancel(), and try/finally. It covers what happens inside a task once it is cancelled, how to run cleanup code, and how to avoid hiding a cancellation request.4 min readasync/await, asyncio.run, and asyncio.create_task. You should also know that Task.cancel() raises CancelledError inside a task at its next await. The earlier chapters on gather and cancellation cover these.5 min readasync/await, can write try/except/finally, and have used asyncio.run and asyncio.create_task. It needs Python 3.11 or newer. You should also know that cancelling a task raises CancelledError inside it, which the earlier chapters on cancellation cover.4 min readasync with asyncio.TaskGroup(), create_task, and how a failing task cancels its siblings. It also assumes Python 3.11 or newer, because ExceptionGroup and except* were added in that release.5 min readasync/await. It also assumes you know try/finally, async with, and how Task.cancel() raises CancelledError (covered in the cancellation chapters). asyncio.timeout builds directly on that mechanism.4 min readasync/await, try/finally, and how asyncio.run starts a program. You should also have read the earlier chapters on cancellation and on asyncio.timeout. asyncio.wait_for is the older way to put a time limit on an awaitable. It is still 4 min readasyncio.TaskGroup, asyncio.timeout, and CancelledError from the earlier chapters. It covers what happens when you combine them, where to place the timeout, and which edge cases can surprise you.5 min readasyncio.create_task, Task.cancel(), how CancelledError propagates, and how asyncio.timeout and asyncio.wait_for behave. It uses Python 3.11 or newer.4 min readasync/await code, you know how asyncio.TaskGroup starts and waits for tasks, and you are on Python 3.11 or newer. You will learn how to cap the number of tasks that use a resource at the same time. You will also learn where to put that cap, and how it interac5 min readasyncio.timeout and asyncio.TaskGroup tell their own cancellation requests apart from everyone else's. It assumes you know Task.cancel(), how CancelledError propagates, and how asyncio.timeout and TaskGroup are used. It needs Python 3.11 or new5 min read