Skip to content

Commit baf75e2

Browse files
jeplerdpgeorge
authored andcommitted
docs/library: Document that sleep(0)/sleep_ms(0) run the scheduler.
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
1 parent 8e3ee30 commit baf75e2

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

docs/library/micropython.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ Functions
130130
a critical region but they will not be executed until that region
131131
is exited. An example of a critical region is a preempting interrupt
132132
handler (an IRQ).
133+
- Inside native code functions, scheduled functions are not called unless
134+
the native code calls a function that specifically does so.
135+
- ``time.sleep`` and ``time.sleep_ms``, including zero-duration sleeps,
136+
will call scheduled functions.
133137

134138
A use for this function is to schedule a callback from a preempting IRQ.
135139
Such an IRQ puts restrictions on the code that runs in the IRQ (for example

docs/library/time.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ Functions
7171
other boards may not accept a floating-point argument, for compatibility with
7272
them use `sleep_ms()` and `sleep_us()` functions.
7373

74+
Calling ``sleep``, including ``sleep(0)`` is guaranteed to call pending callback
75+
functions.
76+
7477
.. function:: sleep_ms(ms)
7578

7679
Delay for given number of milliseconds, should be positive or 0.
@@ -80,6 +83,9 @@ Functions
8083
interrupt handlers or other threads. Passing in 0 for *ms* will still allow
8184
this other processing to occur. Use `sleep_us()` for more precise delays.
8285

86+
Calling ``sleep_ms``, including ``sleep_ms(0)`` is guaranteed to call
87+
pending callback functions.
88+
8389
.. function:: sleep_us(us)
8490

8591
Delay for given number of microseconds, should be positive or 0.

0 commit comments

Comments
 (0)