mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
gh-129874: avoid mixing pure python and C implementation of asyncio (#129875)
This commit is contained in:
parent
6fbf15f98e
commit
d5796e64e0
1 changed files with 7 additions and 7 deletions
|
@ -245,23 +245,23 @@ class Task(futures._PyFuture): # Inherit Python Task implementation
|
||||||
return self._num_cancels_requested
|
return self._num_cancels_requested
|
||||||
|
|
||||||
def __eager_start(self):
|
def __eager_start(self):
|
||||||
prev_task = _swap_current_task(self._loop, self)
|
prev_task = _py_swap_current_task(self._loop, self)
|
||||||
try:
|
try:
|
||||||
_register_eager_task(self)
|
_py_register_eager_task(self)
|
||||||
try:
|
try:
|
||||||
self._context.run(self.__step_run_and_handle_result, None)
|
self._context.run(self.__step_run_and_handle_result, None)
|
||||||
finally:
|
finally:
|
||||||
_unregister_eager_task(self)
|
_py_unregister_eager_task(self)
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
curtask = _swap_current_task(self._loop, prev_task)
|
curtask = _py_swap_current_task(self._loop, prev_task)
|
||||||
assert curtask is self
|
assert curtask is self
|
||||||
finally:
|
finally:
|
||||||
if self.done():
|
if self.done():
|
||||||
self._coro = None
|
self._coro = None
|
||||||
self = None # Needed to break cycles when an exception occurs.
|
self = None # Needed to break cycles when an exception occurs.
|
||||||
else:
|
else:
|
||||||
_register_task(self)
|
_py_register_task(self)
|
||||||
|
|
||||||
def __step(self, exc=None):
|
def __step(self, exc=None):
|
||||||
if self.done():
|
if self.done():
|
||||||
|
@ -273,11 +273,11 @@ class Task(futures._PyFuture): # Inherit Python Task implementation
|
||||||
self._must_cancel = False
|
self._must_cancel = False
|
||||||
self._fut_waiter = None
|
self._fut_waiter = None
|
||||||
|
|
||||||
_enter_task(self._loop, self)
|
_py_enter_task(self._loop, self)
|
||||||
try:
|
try:
|
||||||
self.__step_run_and_handle_result(exc)
|
self.__step_run_and_handle_result(exc)
|
||||||
finally:
|
finally:
|
||||||
_leave_task(self._loop, self)
|
_py_leave_task(self._loop, self)
|
||||||
self = None # Needed to break cycles when an exception occurs.
|
self = None # Needed to break cycles when an exception occurs.
|
||||||
|
|
||||||
def __step_run_and_handle_result(self, exc):
|
def __step_run_and_handle_result(self, exc):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue