File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -273,12 +273,15 @@ def __step(self, exc=None):
273273 self ._must_cancel = False
274274 self ._fut_waiter = None
275275
276- _py_enter_task (self ._loop , self )
276+ prev_task = _py_swap_current_task (self ._loop , self )
277277 try :
278278 self .__step_run_and_handle_result (exc )
279279 finally :
280- _py_leave_task (self ._loop , self )
281- self = None # Needed to break cycles when an exception occurs.
280+ try :
281+ curtask = _py_swap_current_task (self ._loop , prev_task )
282+ assert curtask is self
283+ finally :
284+ self = None # Needed to break cycles when an exception occurs.
282285
283286 def __step_run_and_handle_result (self , exc ):
284287 coro = self ._coro
@@ -1099,6 +1102,9 @@ def _swap_current_task(loop, task):
10991102 del _current_tasks [loop ]
11001103 else :
11011104 _current_tasks [loop ] = task
1105+ if _c_swap_current_task is not _py_swap_current_task :
1106+ # keep the C task state in sync
1107+ _c_swap_current_task (loop , task )
11021108 return prev_task
11031109
11041110
You can’t perform that action at this time.
0 commit comments