Skip to content

Commit 3bf5fd3

Browse files
committed
remove push_head, push_sorted, pop_head
1 parent b74b18e commit 3bf5fd3

File tree

5 files changed

+14
-31
lines changed

5 files changed

+14
-31
lines changed

Diff for: asyncio/core.py

+8-16
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ def __await__(self):
8181

8282
def __next__(self):
8383
if self.state is not None:
84-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push()
85-
_task_queue.push_sorted(cur_task, self.state)
84+
_task_queue.push(cur_task, self.state)
8685
self.state = None
8786
return None
8887
else:
@@ -209,13 +208,11 @@ def wait_io_event(self, dt):
209208
# print('poll', s, sm, ev)
210209
if ev & ~select.POLLOUT and sm[0] is not None:
211210
# POLLIN or error
212-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push()
213-
_task_queue.push_head(sm[0])
211+
_task_queue.push(sm[0])
214212
sm[0] = None
215213
if ev & ~select.POLLIN and sm[1] is not None:
216214
# POLLOUT or error
217-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push()
218-
_task_queue.push_head(sm[1])
215+
_task_queue.push(sm[1])
219216
sm[1] = None
220217
if sm[0] is None and sm[1] is None:
221218
self._dequeue(s)
@@ -245,8 +242,7 @@ def create_task(coro):
245242
if not hasattr(coro, "send"):
246243
raise TypeError("coroutine expected")
247244
t = Task(coro, globals())
248-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push()
249-
_task_queue.push_head(t)
245+
_task_queue.push(t)
250246
return t
251247

252248

@@ -275,8 +271,7 @@ def run_until_complete(main_task=None):
275271
_io_queue.wait_io_event(dt)
276272

277273
# Get next task to run and continue it
278-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .pop()
279-
t = _task_queue.pop_head()
274+
t = _task_queue.pop()
280275
cur_task = t
281276
try:
282277
# Continue running the coroutine, it's responsible for rescheduling itself
@@ -313,17 +308,15 @@ def run_until_complete(main_task=None):
313308
else:
314309
# Schedule any other tasks waiting on the completion of this task.
315310
while t.state.peek():
316-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() and .pop()
317-
_task_queue.push_head(t.state.pop_head())
311+
_task_queue.push(t.state.pop())
318312
waiting = True
319313
# "False" indicates that the task is complete and has been await'ed on.
320314
t.state = False
321315
if not waiting and not isinstance(er, excs_stop):
322316
# An exception ended this detached task, so queue it for later
323317
# execution to handle the uncaught exception if no other task retrieves
324318
# the exception in the meantime (this is handled by Task.throw).
325-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push()
326-
_task_queue.push_head(t)
319+
_task_queue.push(t)
327320
# Save return value of coro to pass up to caller.
328321
t.data = er
329322
elif t.state is None:
@@ -397,8 +390,7 @@ def stop():
397390

398391
global _stop_task
399392
if _stop_task is not None:
400-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push()
401-
_task_queue.push_head(_stop_task)
393+
_task_queue.push(_stop_task)
402394
# If stop() is called again, do nothing
403395
_stop_task = None
404396

Diff for: asyncio/event.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def set(self):
4242
# Note: This must not be called from anything except the thread running
4343
# the asyncio loop (i.e. neither hard or soft IRQ, or a different thread).
4444
while self.waiting.peek():
45-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() and .pop()
46-
core._task_queue.push_head(self.waiting.pop_head())
45+
core._task_queue.push(self.waiting.pop())
4746
self.state = True
4847

4948
def clear(self):
@@ -61,8 +60,7 @@ async def wait(self):
6160

6261
if not self.state:
6362
# Event not set, put the calling task on the event's waiting queue
64-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push()
65-
self.waiting.push_head(core.cur_task)
63+
self.waiting.push(core.cur_task)
6664
# Set calling task's data to the event's queue so it can be removed if needed
6765
core.cur_task.data = self.waiting
6866
# CIRCUITPY-CHANGE: use await; never reschedule

Diff for: asyncio/funcs.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ def done(t, er):
122122
# Still some sub-tasks running.
123123
return
124124
# Gather waiting is done, schedule the main gather task.
125-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push()
126-
core._task_queue.push_head(gather_task)
125+
core._task_queue.push(gather_task)
127126

128127
# Prepare the sub-tasks for the gather.
129128
# The `state` variable counts the number of tasks to wait for, and can be negative

Diff for: asyncio/lock.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ def release(self):
5555
raise RuntimeError("Lock not acquired")
5656
if self.waiting.peek():
5757
# Task(s) waiting on lock, schedule next Task
58-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .pop() and .push()
59-
self.state = self.waiting.pop_head()
60-
core._task_queue.push_head(self.state)
58+
self.state = self.waiting.pop()
59+
core._task_queue.push(self.state)
6160
else:
6261
# No Task waiting so unlock
6362
self.state = 0
@@ -71,8 +70,7 @@ async def acquire(self):
7170

7271
if self.state != 0:
7372
# Lock unavailable, put the calling Task on the waiting queue
74-
# CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push()
75-
self.waiting.push_head(core.cur_task)
73+
self.waiting.push(core.cur_task)
7674
# Set calling task's data to the lock's queue so it can be removed if needed
7775
core.cur_task.data = self.waiting
7876
try:

Diff for: asyncio/task.py

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

131-
# CIRCUITPY-CHANGE: Compatibility aliases, remove after 8.x is no longer supported
132-
push_head = push
133-
push_sorted = push
134-
pop_head = pop
135131

136132
# Task class representing a coroutine, can be waited on and cancelled.
137133
class Task:

0 commit comments

Comments
 (0)