From fa68e11c878527319094e6e46d7415fd3384ceb7 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 16 Aug 2024 19:10:14 -0400 Subject: [PATCH] make more routines async --- asyncio/core.py | 6 ++++-- asyncio/funcs.py | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/asyncio/core.py b/asyncio/core.py index 8a4eb1d..7cf3ff0 100644 --- a/asyncio/core.py +++ b/asyncio/core.py @@ -92,7 +92,8 @@ def __next__(self): # Pause task execution for the given time (integer in milliseconds, uPy extension) # Use a SingletonGenerator to do it without allocating on the heap -def sleep_ms(t, sgen=SingletonGenerator()): +# CIRCUITPY-CHANGE: async +async def sleep_ms(t, sgen=SingletonGenerator()): # CIRCUITPY-CHANGE: doc """Sleep for *t* milliseconds. @@ -106,7 +107,8 @@ def sleep_ms(t, sgen=SingletonGenerator()): # Pause task execution for the given time (in seconds) -def sleep(t): +# CIRCUITPY-CHANGE: async +async def sleep(t): # CIRCUITPY-CHANGE: doc """Sleep for *t* seconds diff --git a/asyncio/funcs.py b/asyncio/funcs.py index 61840d0..c7b83c3 100644 --- a/asyncio/funcs.py +++ b/asyncio/funcs.py @@ -76,14 +76,15 @@ async def wait_for(aw, timeout, sleep=core.sleep): raise core.TimeoutError -def wait_for_ms(aw, timeout): +#CIRCUITPY-CHANGE: async +async def wait_for_ms(aw, timeout): # CIRCUITPY-CHANGE: doc """Similar to `wait_for` but *timeout* is an integer in milliseconds. This is a coroutine, and a MicroPython extension. """ - return wait_for(aw, timeout, core.sleep_ms) + return await wait_for(aw, timeout, core.sleep_ms) class _Remove: