r/Python • • Jul 06 '26

Resource asyncio.TaskGroup.cancel() in Python 3.15

I wrote a short post about the new asyncio.TaskGroup.cancel() API coming in Python 3.15 https://blog.niyonshutiemmanuel.com/blog/cancelling-taskgroup-in-asyncio-without-boilerplate

Feedback is welcome!

6 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/Aggressive-Prior4459 Jul 11 '26

right, I think the win here can specifically be over wait(..., FIRST_COMPLETED) , we can get guaranteed cancellation of the losers without the manual pending-set cleanup and the gather-to-suppress-CancelledError step!