summaryrefslogtreecommitdiffstatshomepage
path: root/extmod/uasyncio/core.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2020-08-20 23:13:25 +1000
committerDamien George <damien@micropython.org>2020-08-22 12:17:06 +1000
commit55c76eaac12af4e93f8de11bb25c835e8b65c623 (patch)
treecf3e4d1ccad90737a076548dddbc84acb8c5dbc6 /extmod/uasyncio/core.py
parent20948a3d54ff560a3d029b8bfc9761dcbbad9312 (diff)
downloadmicropython-55c76eaac12af4e93f8de11bb25c835e8b65c623.tar.gz
micropython-55c76eaac12af4e93f8de11bb25c835e8b65c623.zip
extmod/uasyncio: Truncate negative sleeps to 0.
Otherwise a task that continuously awaits on a large negative sleep can monopolise the scheduler (because its wake time is always less than everything else in the pairing heap). Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod/uasyncio/core.py')
-rw-r--r--extmod/uasyncio/core.py2
1 files changed, 1 insertions, 1 deletions
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