TaskGroup vs asyncio.gather: Choosing the Right Cancellation Strategy for Deterministic Resource Cleanup
Goal Determine a cancellation strategy that guarantees deterministic cleanup of external resources in concurrent Python code. Constraint Python 3.11’s asyncio.TaskGroup automatically cancels all child tasks when the group is cancelled, but the order in which those cancellations propagate is unspecified. In contrast, manual cancellation via asyncio.gather all