mirror of
https://github.com/micropython/micropython.git
synced 2026-01-28 06:40:19 +01:00
extmod/modselect: Handle pending events before entering poll.
This allows tests like `asyncio_event_queue.py` to succeed under the native emitter when poll is enabled. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This commit is contained in:
committed by
Damien George
parent
8248d11806
commit
2782d4598d
@@ -132,7 +132,8 @@ Functions
|
||||
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,
|
||||
- Certain functions including ``poll.poll``, ``poll.ipoll``,
|
||||
``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.
|
||||
|
||||
@@ -76,6 +76,9 @@ Methods
|
||||
|
||||
In case of timeout, an empty list is returned.
|
||||
|
||||
Calling ``poll.poll`` is guaranteed to call pending callback functions
|
||||
before entering the polling loop.
|
||||
|
||||
.. admonition:: Difference to CPython
|
||||
:class: attention
|
||||
|
||||
@@ -93,6 +96,9 @@ Methods
|
||||
won't be processed until new mask is set with `poll.modify()`. This
|
||||
behaviour is useful for asynchronous I/O schedulers.
|
||||
|
||||
Calling ``poll.ipoll`` is guaranteed to call pending callback functions
|
||||
before entering the polling loop.
|
||||
|
||||
.. admonition:: Difference to CPython
|
||||
:class: attention
|
||||
|
||||
|
||||
@@ -342,6 +342,8 @@ static mp_uint_t poll_set_poll_until_ready_or_timeout(poll_set_t *poll_set, size
|
||||
mp_uint_t start_ticks = mp_hal_ticks_ms();
|
||||
bool has_timeout = timeout != (mp_uint_t)-1;
|
||||
|
||||
mp_handle_pending(true);
|
||||
|
||||
#if MICROPY_PY_SELECT_POSIX_OPTIMISATIONS
|
||||
|
||||
for (;;) {
|
||||
|
||||
Reference in New Issue
Block a user