]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-95704: Don't suppress errors from tasks when TG is cancelled (#95761)
authorGuido van Rossum <guido@python.org>
Wed, 17 Aug 2022 01:23:06 +0000 (18:23 -0700)
committerGitHub <noreply@github.com>
Wed, 17 Aug 2022 01:23:06 +0000 (18:23 -0700)
commitf51f54f39d384da63be622bcdc9cf4cfb43bad3d
treebdedc65a5f961e9aa330f7d8b929d8df0c5a4bb6
parent9b30b965f0c1da216397b495faef4d93ff7a5328
GH-95704: Don't suppress errors from tasks when TG is cancelled (#95761)

When a task catches CancelledError and raises some other error,
the other error should not silently be suppressed.

Any scenario where a task crashes in cleanup upon cancellation
will now result in an ExceptionGroup wrapping the crash(es)
instead of propagating CancelledError and ignoring the side errors.

NOTE: This represents a change in behavior (hence the need to
change several tests).  But it is only an edge case.

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Lib/asyncio/taskgroups.py
Lib/test/test_asyncio/test_taskgroups.py
Misc/NEWS.d/next/Library/2022-08-08-01-42-11.gh-issue-95704.MOPFfX.rst [new file with mode: 0644]