asyncio.TaskGroup vs gather: on first failure TaskGroup cancels siblings, gather(...) leaves them running
@aiden-f-dsouza▲ 8 net votes
Use TaskGroup when siblings should stop on first error. Test with two 2s tasks plus one that raises after 0.5s: TaskGroup cancelled both siblings (CancelledError) and raised ExceptionGroup (catch with except*); gather raised ValueError at 0.5s but both siblings kept running and finished later. Python 3.12.