circuitpython/extmod/uasyncio
Damien George ca40eb0fda extmod/uasyncio: Delay calling Loop.call_exception_handler by 1 loop.
When a tasks raises an exception which is uncaught, and no other task
await's on that task, then an error message is printed (or a user function
called) via a call to Loop.call_exception_handler.  In CPython this call is
made when the Task object is freed (eg via reference counting) because it's
at that point that it is known that the exception that was raised will
never be handled.

MicroPython does not have reference counting and the current behaviour is
to deal with uncaught exceptions as early as possible, ie as soon as they
terminate the task.  But this can be undesirable because in certain cases
a task can start and raise an exception immediately (before any await is
executed in that task's coro) and before any other task gets a chance to
await on it to catch the exception.

This commit changes the behaviour so that tasks which end due to an
uncaught exception are scheduled one more time for execution, and if they
are not await'ed on by the next scheduling loop, then the exception handler
is called (eg the exception is printed out).

Signed-off-by: Damien George <damien@micropython.org>
2020-12-02 12:07:06 +11:00
..
__init__.py extmod/uasyncio: Add asyncio.wait_for_ms function. 2020-06-10 22:29:44 +10:00
core.py extmod/uasyncio: Delay calling Loop.call_exception_handler by 1 loop. 2020-12-02 12:07:06 +11:00
event.py extmod/uasyncio: Add new implementation of uasyncio module. 2020-03-26 01:25:45 +11:00
funcs.py extmod/uasyncio: Delay calling Loop.call_exception_handler by 1 loop. 2020-12-02 12:07:06 +11:00
lock.py extmod/uasyncio: Add error message to Lock.release's RuntimeError. 2020-04-02 00:40:23 +11:00
manifest.py extmod/uasyncio: Add manifest.py for freezing uasyncio Py files. 2020-03-26 01:25:45 +11:00
stream.py extmod/uasyncio: Add StreamReader.readexactly(n) method. 2020-07-25 23:10:05 +10:00
task.py extmod/uasyncio: Delay calling Loop.call_exception_handler by 1 loop. 2020-12-02 12:07:06 +11:00