summaryrefslogtreecommitdiffstatshomepage
path: root/extmod/uasyncio/funcs.py
diff options
context:
space:
mode:
Diffstat (limited to 'extmod/uasyncio/funcs.py')
-rw-r--r--extmod/uasyncio/funcs.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/extmod/uasyncio/funcs.py b/extmod/uasyncio/funcs.py
index 7a4bddf256..6e1305c94f 100644
--- a/extmod/uasyncio/funcs.py
+++ b/extmod/uasyncio/funcs.py
@@ -4,16 +4,16 @@
from . import core
-async def wait_for(aw, timeout):
+async def wait_for(aw, timeout, sleep=core.sleep):
aw = core._promote_to_task(aw)
if timeout is None:
return await aw
- def cancel(aw, timeout):
- await core.sleep(timeout)
+ def cancel(aw, timeout, sleep):
+ await sleep(timeout)
aw.cancel()
- cancel_task = core.create_task(cancel(aw, timeout))
+ cancel_task = core.create_task(cancel(aw, timeout, sleep))
try:
ret = await aw
except core.CancelledError:
@@ -29,6 +29,10 @@ async def wait_for(aw, timeout):
return ret
+def wait_for_ms(aw, timeout):
+ return wait_for(aw, timeout, core.sleep_ms)
+
+
async def gather(*aws, return_exceptions=False):
ts = [core._promote_to_task(aw) for aw in aws]
for i in range(len(ts)):