aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/asyncio/taskgroups.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-01-09 21:41:31 +0200
committerGitHub <noreply@github.com>2024-01-09 21:41:31 +0200
commita5db6a3351b440a875a5af84a8b2447981356e34 (patch)
tree1add2b8a6ef3511e9f2480d6bad8c48f5cdab768 /Lib/asyncio/taskgroups.py
parent5273655bea050432756098641b9fda72361bf983 (diff)
downloadcpython-a5db6a3351b440a875a5af84a8b2447981356e34.tar.gz
cpython-a5db6a3351b440a875a5af84a8b2447981356e34.zip
gh-113848: Handle CancelledError subclasses in asyncio TaskGroup() and timeout() (GH-113850)
Diffstat (limited to 'Lib/asyncio/taskgroups.py')
-rw-r--r--Lib/asyncio/taskgroups.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/asyncio/taskgroups.py b/Lib/asyncio/taskgroups.py
index cb9c1ce4d7d..e1c56d140be 100644
--- a/Lib/asyncio/taskgroups.py
+++ b/Lib/asyncio/taskgroups.py
@@ -73,8 +73,10 @@ class TaskGroup:
self._base_error is None):
self._base_error = exc
- propagate_cancellation_error = \
- exc if et is exceptions.CancelledError else None
+ if et is not None and issubclass(et, exceptions.CancelledError):
+ propagate_cancellation_error = exc
+ else:
+ propagate_cancellation_error = None
if self._parent_cancel_requested:
# If this flag is set we *must* call uncancel().
if self._parent_task.uncancel() == 0:
@@ -133,7 +135,7 @@ class TaskGroup:
if propagate_cancellation_error and not self._errors:
raise propagate_cancellation_error
- if et is not None and et is not exceptions.CancelledError:
+ if et is not None and not issubclass(et, exceptions.CancelledError):
self._errors.append(exc)
if self._errors: