Skip to content

Commit 7c25d09

Browse files
committed
revert the rename of push and pop methods
choose the way that is compatible with 8.x and 9.x
1 parent 510d4a3 commit 7c25d09

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

asyncio/core.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __await__(self):
6262

6363
def __next__(self):
6464
if self.state is not None:
65-
_task_queue.push(cur_task, self.state)
65+
_task_queue.push_sorted(cur_task, self.state)
6666
self.state = None
6767
return None
6868
else:
@@ -179,11 +179,11 @@ def wait_io_event(self, dt):
179179
# print('poll', s, sm, ev)
180180
if ev & ~select.POLLOUT and sm[0] is not None:
181181
# POLLIN or error
182-
_task_queue.push(sm[0])
182+
_task_queue.push_head(sm[0])
183183
sm[0] = None
184184
if ev & ~select.POLLIN and sm[1] is not None:
185185
# POLLOUT or error
186-
_task_queue.push(sm[1])
186+
_task_queue.push_head(sm[1])
187187
sm[1] = None
188188
if sm[0] is None and sm[1] is None:
189189
self._dequeue(s)
@@ -211,7 +211,7 @@ def create_task(coro):
211211
if not hasattr(coro, "send"):
212212
raise TypeError("coroutine expected")
213213
t = Task(coro, globals())
214-
_task_queue.push(t)
214+
_task_queue.push_head(t)
215215
return t
216216

217217

@@ -238,7 +238,7 @@ def run_until_complete(main_task=None):
238238
_io_queue.wait_io_event(dt)
239239

240240
# Get next task to run and continue it
241-
t = _task_queue.pop()
241+
t = _task_queue.pop_head()
242242
cur_task = t
243243
try:
244244
# Continue running the coroutine, it's responsible for rescheduling itself
@@ -274,15 +274,15 @@ def run_until_complete(main_task=None):
274274
else:
275275
# Schedule any other tasks waiting on the completion of this task.
276276
while t.state.peek():
277-
_task_queue.push(t.state.pop())
277+
_task_queue.push_head(t.state.pop_head())
278278
waiting = True
279279
# "False" indicates that the task is complete and has been await'ed on.
280280
t.state = False
281281
if not waiting and not isinstance(er, excs_stop):
282282
# An exception ended this detached task, so queue it for later
283283
# execution to handle the uncaught exception if no other task retrieves
284284
# the exception in the meantime (this is handled by Task.throw).
285-
_task_queue.push(t)
285+
_task_queue.push_head(t)
286286
# Save return value of coro to pass up to caller.
287287
t.data = er
288288
elif t.state is None:
@@ -344,7 +344,7 @@ def stop():
344344

345345
global _stop_task
346346
if _stop_task is not None:
347-
_task_queue.push(_stop_task)
347+
_task_queue.push_head(_stop_task)
348348
# If stop() is called again, do nothing
349349
_stop_task = None
350350

asyncio/event.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def set(self):
4040
# Note: This must not be called from anything except the thread running
4141
# the asyncio loop (i.e. neither hard or soft IRQ, or a different thread).
4242
while self.waiting.peek():
43-
core._task_queue.push(self.waiting.pop())
43+
core._task_queue.push_head(self.waiting.pop_head())
4444
self.state = True
4545

4646
def clear(self):
@@ -57,7 +57,7 @@ async def wait(self):
5757

5858
if not self.state:
5959
# Event not set, put the calling task on the event's waiting queue
60-
self.waiting.push(core.cur_task)
60+
self.waiting.push_head(core.cur_task)
6161
# Set calling task's data to the event's queue so it can be removed if needed
6262
core.cur_task.data = self.waiting
6363
await core._never()

asyncio/funcs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def done(t, er):
116116
# Still some sub-tasks running.
117117
return
118118
# Gather waiting is done, schedule the main gather task.
119-
core._task_queue.push(gather_task)
119+
core._task_queue.push_head(gather_task)
120120

121121
ts = [core._promote_to_task(aw) for aw in aws]
122122
for i in range(len(ts)):

asyncio/lock.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def release(self):
5050
raise RuntimeError("Lock not acquired")
5151
if self.waiting.peek():
5252
# Task(s) waiting on lock, schedule next Task
53-
self.state = self.waiting.pop()
54-
core._task_queue.push(self.state)
53+
self.state = self.waiting.pop_head()
54+
core._task_queue.push_head(self.state)
5555
else:
5656
# No Task waiting so unlock
5757
self.state = 0
@@ -65,7 +65,7 @@ async def acquire(self):
6565

6666
if self.state != 0:
6767
# Lock unavailable, put the calling Task on the waiting queue
68-
self.waiting.push(core.cur_task)
68+
self.waiting.push_head(core.cur_task)
6969
# Set calling task's data to the lock's queue so it can be removed if needed
7070
core.cur_task.data = self.waiting
7171
try:

asyncio/task.py

+4
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ def pop(self):
130130
def remove(self, v):
131131
self.heap = ph_delete(self.heap, v)
132132

133+
# Compatibility aliases, remove after they are no longer used
134+
push_head = push
135+
push_sorted = push
136+
pop_head = pop
133137

134138
# Task class representing a coroutine, can be waited on and cancelled.
135139
class Task:

0 commit comments

Comments
 (0)