From 3bf5fd3cbc0bb0731f5a79253eec6a08e0426648 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 10 Apr 2025 16:27:31 -0400 Subject: [PATCH] remove push_head, push_sorted, pop_head --- asyncio/core.py | 24 ++++++++---------------- asyncio/event.py | 6 ++---- asyncio/funcs.py | 3 +-- asyncio/lock.py | 8 +++----- asyncio/task.py | 4 ---- 5 files changed, 14 insertions(+), 31 deletions(-) diff --git a/asyncio/core.py b/asyncio/core.py index 8937eba..1024ad2 100644 --- a/asyncio/core.py +++ b/asyncio/core.py @@ -81,8 +81,7 @@ def __await__(self): def __next__(self): if self.state is not None: - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() - _task_queue.push_sorted(cur_task, self.state) + _task_queue.push(cur_task, self.state) self.state = None return None else: @@ -209,13 +208,11 @@ def wait_io_event(self, dt): # print('poll', s, sm, ev) if ev & ~select.POLLOUT and sm[0] is not None: # POLLIN or error - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() - _task_queue.push_head(sm[0]) + _task_queue.push(sm[0]) sm[0] = None if ev & ~select.POLLIN and sm[1] is not None: # POLLOUT or error - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() - _task_queue.push_head(sm[1]) + _task_queue.push(sm[1]) sm[1] = None if sm[0] is None and sm[1] is None: self._dequeue(s) @@ -245,8 +242,7 @@ def create_task(coro): if not hasattr(coro, "send"): raise TypeError("coroutine expected") t = Task(coro, globals()) - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() - _task_queue.push_head(t) + _task_queue.push(t) return t @@ -275,8 +271,7 @@ def run_until_complete(main_task=None): _io_queue.wait_io_event(dt) # Get next task to run and continue it - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .pop() - t = _task_queue.pop_head() + t = _task_queue.pop() cur_task = t try: # Continue running the coroutine, it's responsible for rescheduling itself @@ -313,8 +308,7 @@ def run_until_complete(main_task=None): else: # Schedule any other tasks waiting on the completion of this task. while t.state.peek(): - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() and .pop() - _task_queue.push_head(t.state.pop_head()) + _task_queue.push(t.state.pop()) waiting = True # "False" indicates that the task is complete and has been await'ed on. t.state = False @@ -322,8 +316,7 @@ def run_until_complete(main_task=None): # An exception ended this detached task, so queue it for later # execution to handle the uncaught exception if no other task retrieves # the exception in the meantime (this is handled by Task.throw). - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() - _task_queue.push_head(t) + _task_queue.push(t) # Save return value of coro to pass up to caller. t.data = er elif t.state is None: @@ -397,8 +390,7 @@ def stop(): global _stop_task if _stop_task is not None: - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() - _task_queue.push_head(_stop_task) + _task_queue.push(_stop_task) # If stop() is called again, do nothing _stop_task = None diff --git a/asyncio/event.py b/asyncio/event.py index bd63cb9..6e527ff 100644 --- a/asyncio/event.py +++ b/asyncio/event.py @@ -42,8 +42,7 @@ def set(self): # Note: This must not be called from anything except the thread running # the asyncio loop (i.e. neither hard or soft IRQ, or a different thread). while self.waiting.peek(): - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() and .pop() - core._task_queue.push_head(self.waiting.pop_head()) + core._task_queue.push(self.waiting.pop()) self.state = True def clear(self): @@ -61,8 +60,7 @@ async def wait(self): if not self.state: # Event not set, put the calling task on the event's waiting queue - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() - self.waiting.push_head(core.cur_task) + self.waiting.push(core.cur_task) # Set calling task's data to the event's queue so it can be removed if needed core.cur_task.data = self.waiting # CIRCUITPY-CHANGE: use await; never reschedule diff --git a/asyncio/funcs.py b/asyncio/funcs.py index 582ffc2..566b32c 100644 --- a/asyncio/funcs.py +++ b/asyncio/funcs.py @@ -122,8 +122,7 @@ def done(t, er): # Still some sub-tasks running. return # Gather waiting is done, schedule the main gather task. - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() - core._task_queue.push_head(gather_task) + core._task_queue.push(gather_task) # Prepare the sub-tasks for the gather. # The `state` variable counts the number of tasks to wait for, and can be negative diff --git a/asyncio/lock.py b/asyncio/lock.py index 2320ebb..034d2f6 100644 --- a/asyncio/lock.py +++ b/asyncio/lock.py @@ -55,9 +55,8 @@ def release(self): raise RuntimeError("Lock not acquired") if self.waiting.peek(): # Task(s) waiting on lock, schedule next Task - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .pop() and .push() - self.state = self.waiting.pop_head() - core._task_queue.push_head(self.state) + self.state = self.waiting.pop() + core._task_queue.push(self.state) else: # No Task waiting so unlock self.state = 0 @@ -71,8 +70,7 @@ async def acquire(self): if self.state != 0: # Lock unavailable, put the calling Task on the waiting queue - # CIRCUITPY-CHANGE: when 8.x support is discontinued, change to .push() - self.waiting.push_head(core.cur_task) + self.waiting.push(core.cur_task) # Set calling task's data to the lock's queue so it can be removed if needed core.cur_task.data = self.waiting try: diff --git a/asyncio/task.py b/asyncio/task.py index af7e700..1d63de3 100644 --- a/asyncio/task.py +++ b/asyncio/task.py @@ -128,10 +128,6 @@ def pop(self): def remove(self, v): self.heap = ph_delete(self.heap, v) - # CIRCUITPY-CHANGE: Compatibility aliases, remove after 8.x is no longer supported - push_head = push - push_sorted = push - pop_head = pop # Task class representing a coroutine, can be waited on and cancelled. class Task: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy