MemotivaAsynchronous programming and asyncio

What is the difference between asyncio.gather and asyncio.TaskGroup?

Asynchronous programming and asyncio

Audio flashcard · 0:15

Nortren·

What is the difference between asyncio.gather and asyncio.TaskGroup?

0:15

Gather is older and more flexible but does not enforce structured concurrency: tasks can outlive the gather call. TaskGroup enforces structured concurrency: all tasks are bounded to the with block, and failures are handled cleanly via exception groups. New code should generally prefer TaskGroup.
docs.python.org