← index #9280Issue #9304
Related · high · value 2.877
QUERY · ISSUE

utime.sleep_us() overflow

openby socketpairopened 2022-09-11updated 2022-09-12
docs
>>> from utime import sleep_us
>>> sleep_us(24*3600*1000_000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: overflow converting long int to machine word

It's not documented about any limits on the argument. Either fix in documentation or fix. Fixing is better.

CANDIDATE · ISSUE

utime.sleep(24*3600) sleeps only 500 seconds on ESP32

closedby socketpairopened 2022-09-14updated 2022-09-14
bugport-esp32

MicroPython v1.19.1 on 2022-06-18; ESP32 module with ESP32

boot.py:

from utime import sleep, time

while True:
    print(time())
    sleep(24 * 3600 - 499) # without - 499 will print every 500 seconds

will print a line roughly at every 1-2 seconds:

1
2
4
6
7
9
11
...

I guess, it's overflow+wraparound issue.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied