Grokking Concurrency in Python
0% completed
TaskGroup
async with asyncio.TaskGroup() as tg: is one line of code, and it does the work of the eight lines of hand-written cleanup in The Trouble With Gather and Loose Tasks. It holds the tasks, cancels the ones still running when any of them fails, and waits until they have stopped. The block does this however it is left, so the caller does not have to remember anything.
What a TaskGroup Is
**A task group is an asynchronous context manager that owns the tasks created through it, and its `async with
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%