8000 [3.11] GH-98543: Fix `asyncio.TaskGroup` to not keep reference to er… · python/cpython@36d25a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 36d25a4

Browse files
[3.11] GH-98543: Fix asyncio.TaskGroup to not keep reference to errors after raising ExceptionGroup (GH-98544) (#98550)
GH-98543: Fix `asyncio.TaskGroup` to not keep reference to errors after raising ExceptionGroup (GH-98544) (cherry picked from commit f4a1494) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
1 parent 032d127 commit 36d25a4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Lib/asyncio/taskgroups.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ async def __aexit__(self, et, exc, tb):
128128
# Exceptions are heavy objects that can have object
129129
# cycles (bad for GC); let's not keep a reference to
130130
# a bunch of them.
131-
errors = self._errors
132-
self._errors = None
133-
134-
me = BaseExceptionGroup('unhandled errors in a TaskGroup', errors)
135-
raise me from None
131+
try:
132+
me = BaseExceptionGroup('unhandled errors in a TaskGroup', self._errors)
133+
raise me from None
134+
finally:
135+
self._errors = None
136136

137137
def create_task(self, coro, *, name=None, context=None):
138138
if not self._entered:

0 commit comments

Comments
 (0)
0