diff options
author | Damien George <damien@micropython.org> | 2020-08-20 23:13:25 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-08-22 12:17:06 +1000 |
commit | 55c76eaac12af4e93f8de11bb25c835e8b65c623 (patch) | |
tree | cf3e4d1ccad90737a076548dddbc84acb8c5dbc6 /extmod/uasyncio/core.py | |
parent | 20948a3d54ff560a3d029b8bfc9761dcbbad9312 (diff) | |
download | micropython-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.py | 2 |
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 |