@@ -62,7 +62,7 @@ def __await__(self):
62
62
63
63
def __next__ (self ):
64
64
if self .state is not None :
65
- _task_queue .push (cur_task , self .state )
65
+ _task_queue .push_sorted (cur_task , self .state )
66
66
self .state = None
67
67
return None
68
68
else :
@@ -179,11 +179,11 @@ def wait_io_event(self, dt):
179
179
# print('poll', s, sm, ev)
180
180
if ev & ~ select .POLLOUT and sm [0 ] is not None :
181
181
# POLLIN or error
182
- _task_queue .push (sm [0 ])
182
+ _task_queue .push_head (sm [0 ])
183
183
sm [0 ] = None
184
184
if ev & ~ select .POLLIN and sm [1 ] is not None :
185
185
# POLLOUT or error
186
- _task_queue .push (sm [1 ])
186
+ _task_queue .push_head (sm [1 ])
187
187
sm [1 ] = None
188
188
if sm [0 ] is None and sm [1 ] is None :
189
189
self ._dequeue (s )
@@ -211,7 +211,7 @@ def create_task(coro):
211
211
if not hasattr (coro , "send" ):
212
212
raise TypeError ("coroutine expected" )
213
213
t = Task (coro , globals ())
214
- _task_queue .push (t )
214
+ _task_queue .push_head (t )
215
215
return t
216
216
217
217
@@ -238,7 +238,7 @@ def run_until_complete(main_task=None):
238
238
_io_queue .wait_io_event (dt )
239
239
240
240
# Get next task to run and continue it
241
- t = _task_queue .pop ()
241
+ t = _task_queue .pop_head ()
242
242
cur_task = t
243
243
try :
244
244
# Continue running the coroutine, it's responsible for rescheduling itself
@@ -274,15 +274,15 @@ def run_until_complete(main_task=None):
274
274
else :
275
275
# Schedule any other tasks waiting on the completion of this task.
276
276
while t .state .peek ():
277
- _task_queue .push (t .state .pop ())
277
+ _task_queue .push_head (t .state .pop_head ())
278
278
waiting = True
279
279
# "False" indicates that the task is complete and has been await'ed on.
280
280
t .state = False
281
281
if not waiting and not isinstance (er , excs_stop ):
282
282
# An exception ended this detached task, so queue it for later
283
283
# execution to handle the uncaught exception if no other task retrieves
284
284
# the exception in the meantime (this is handled by Task.throw).
285
- _task_queue .push (t )
285
+ _task_queue .push_head (t )
286
286
# Save return value of coro to pass up to caller.
287
287
t .data = er
288
288
elif t .state is None :
@@ -344,7 +344,7 @@ def stop():
344
344
345
345
global _stop_task
346
346
if _stop_task is not None :
347
- _task_queue .push (_stop_task )
347
+ _task_queue .push_head (_stop_task )
348
348
# If stop() is called again, do nothing
349
349
_stop_task = None
350
350
0 commit comments