extmod/asyncio: Fix early exit of asyncio scheduler.

This commit fixes three open issues related to the asyncio scheduler
exiting prematurely when the main task queue is empty, in cases where
CPython would not exit (for example, because the main task is not done
because it's on a different queue).

In the first case, the scheduler exits because running a task via
`run_until_complete` did not schedule any dependent tasks.

In the other two cases, the scheduler exits because the tasks are queued in
an event queue.

Tests have been added which reproduce the original issues.  These test
cases document the unauthorized use of `Event.set()` from a soft IRQ, and
are skipped in unsupported environments (webassembly and native emitter).

Fixes issues #16759, #16569 and #16318.

Signed-off-by: Yoctopuce dev <dev@yoctopuce.com>
This commit is contained in:
Yoctopuce dev
2025-02-15 15:24:50 +01:00
committed by Damien George
parent 79abdad9e9
commit bdb7e036d2
7 changed files with 255 additions and 12 deletions

View File

@@ -0,0 +1,5 @@
main started
foo waiting
asyncio still pending, unlocking event
foo done
main done