Skip to content

gh-129874: avoid mixing pure python and C implementation of asyncio #129875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Lib/asyncio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,23 +245,23 @@ def uncancel(self):
return self._num_cancels_requested

def __eager_start(self):
prev_task = _swap_current_task(self._loop, self)
prev_task = _py_swap_current_task(self._loop, self)
try:
_register_eager_task(self)
_py_register_eager_task(self)
try:
self._context.run(self.__step_run_and_handle_result, None)
finally:
_unregister_eager_task(self)
_py_unregister_eager_task(self)
finally:
try:
curtask = _swap_current_task(self._loop, prev_task)
curtask = _py_swap_current_task(self._loop, prev_task)
assert curtask is self
finally:
if self.done():
self._coro = None
self = None # Needed to break cycles when an exception occurs.
else:
_register_task(self)
_py_register_task(self)

def __step(self, exc=None):
if self.done():
Expand All @@ -273,11 +273,11 @@ def __step(self, exc=None):
self._must_cancel = False
self._fut_waiter = None

_enter_task(self._loop, self)
_py_enter_task(self._loop, self)
try:
self.__step_run_and_handle_result(exc)
finally:
_leave_task(self._loop, self)
_py_leave_task(self._loop, self)
self = None # Needed to break cycles when an exception occurs.

def __step_run_and_handle_result(self, exc):
Expand Down
Loading