diff --git a/extmod/uasyncio/core.py b/extmod/uasyncio/core.py index 689487d36a..045b4cd139 100644 --- a/extmod/uasyncio/core.py +++ b/extmod/uasyncio/core.py @@ -53,7 +53,7 @@ class SingletonGenerator: # Use a SingletonGenerator to do it without allocating on the heap def sleep_ms(t, sgen=SingletonGenerator()): assert sgen.state is None - sgen.state = ticks_add(ticks(), t) + sgen.state = ticks_add(ticks(), max(0, t)) return sgen diff --git a/tests/extmod/uasyncio_fair.py b/tests/extmod/uasyncio_fair.py index 9b04454bc1..e0ee811a9b 100644 --- a/tests/extmod/uasyncio_fair.py +++ b/tests/extmod/uasyncio_fair.py @@ -22,6 +22,7 @@ async def main(): t1 = asyncio.create_task(task(1, -0.01)) t2 = asyncio.create_task(task(2, 0.1)) t3 = asyncio.create_task(task(3, 0.2)) + t3 = asyncio.create_task(task(4, -100)) await asyncio.sleep(0.5) t1.cancel() t2.cancel() diff --git a/tests/extmod/uasyncio_fair.py.exp b/tests/extmod/uasyncio_fair.py.exp index 4428943f46..b4b6481db0 100644 --- a/tests/extmod/uasyncio_fair.py.exp +++ b/tests/extmod/uasyncio_fair.py.exp @@ -3,6 +3,7 @@ task start 2 task work 2 task start 3 task work 3 +task start 4 task work 2 task work 3 task work 2