@@ -90,11 +90,7 @@ def task_done(task):
9090 return
9191 unhandled_exceptions .append (exc )
9292
93- async def run_one_coro (ok_to_start , previous_failed ) -> None :
94- # in eager tasks this waits for the calling task to append this task
95- # to running_tasks, in regular tasks this wait is a no-op that does
96- # not yield a future. See gh-124309.
97- await ok_to_start .wait ()
93+ async def run_one_coro (previous_failed ) -> None :
9894 # Wait for the previous task to finish, or for delay seconds
9995 if previous_failed is not None :
10096 with contextlib .suppress (exceptions_mod .TimeoutError ):
@@ -110,14 +106,13 @@ async def run_one_coro(ok_to_start, previous_failed) -> None:
110106 return
111107 # Start task that will run the next coroutine
112108 this_failed = locks .Event ()
113- next_ok_to_start = locks .Event ()
114- next_task = loop .create_task (run_one_coro (next_ok_to_start , this_failed ))
109+ next_task = loop .create_task (
110+ run_one_coro (this_failed ),
111+ eager_start = False ,
112+ )
115113 futures .future_add_to_awaited_by (next_task , parent_task )
116114 running_tasks .add (next_task )
117115 next_task .add_done_callback (task_done )
118- # next_task has been appended to running_tasks so next_task is ok to
119- # start.
120- next_ok_to_start .set ()
121116 # Prepare place to put this coroutine's exceptions if not won
122117 exceptions .append (None )
123118 assert len (exceptions ) == this_index + 1
@@ -149,13 +144,11 @@ async def run_one_coro(ok_to_start, previous_failed) -> None:
149144
150145 propagate_cancellation_error = None
151146 try :
152- ok_to_start = locks .Event ()
153- first_task = loop .create_task (run_one_coro (ok_to_start , None ))
147+ first_task = loop .create_task (run_one_coro (None ), eager_start = False )
154148 futures .future_add_to_awaited_by (first_task , parent_task )
155149 running_tasks .add (first_task )
156150 first_task .add_done_callback (task_done )
157151 # first_task has been appended to running_tasks so first_task is ok to start.
158- ok_to_start .set ()
159152 propagate_cancellation_error = None
160153 # Make sure no tasks are left running if we leave this function
161154 while running_tasks :
0 commit comments