Skip to content

Commit

Permalink
Fix test_task_exc_handler_correct_context
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Bower <jbower@meta.com>
  • Loading branch information
itamaro and jbower-fb committed Apr 21, 2023
1 parent e7743f6 commit 10a03a0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Lib/asyncio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def __eager_start(self):
finally:
if self.done():
self._coro = None
self = None # Needed to break cycles when an exception occurs.
else:
_register_task(self)

Expand Down Expand Up @@ -365,6 +366,8 @@ def __step_run_and_handle_result(self, exc):
new_exc = RuntimeError(f'Task got bad yield: {result!r}')
self._loop.call_soon(
self.__step, new_exc, context=self._context)
finally:
self = None # Needed to break cycles when an exception occurs.

def __wakeup(self, future):
try:
Expand Down

0 comments on commit 10a03a0

Please sign in to comment.