docs/library: Document that sleep(0)/sleep_ms(0) run the scheduler.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This commit is contained in:
Jeff Epler
2025-11-27 19:40:51 -06:00
committed by Damien George
parent 8e3ee303ce
commit baf75e21d3
2 changed files with 10 additions and 0 deletions

View File

@@ -130,6 +130,10 @@ Functions
a critical region but they will not be executed until that region
is exited. An example of a critical region is a preempting interrupt
handler (an IRQ).
- Inside native code functions, scheduled functions are not called unless
the native code calls a function that specifically does so.
- ``time.sleep`` and ``time.sleep_ms``, including zero-duration sleeps,
will call scheduled functions.
A use for this function is to schedule a callback from a preempting IRQ.
Such an IRQ puts restrictions on the code that runs in the IRQ (for example

View File

@@ -71,6 +71,9 @@ Functions
other boards may not accept a floating-point argument, for compatibility with
them use `sleep_ms()` and `sleep_us()` functions.
Calling ``sleep``, including ``sleep(0)`` is guaranteed to call pending callback
functions.
.. function:: sleep_ms(ms)
Delay for given number of milliseconds, should be positive or 0.
@@ -80,6 +83,9 @@ Functions
interrupt handlers or other threads. Passing in 0 for *ms* will still allow
this other processing to occur. Use `sleep_us()` for more precise delays.
Calling ``sleep_ms``, including ``sleep_ms(0)`` is guaranteed to call
pending callback functions.
.. function:: sleep_us(us)
Delay for given number of microseconds, should be positive or 0.