diff options
author | Damien George <damien@micropython.org> | 2024-01-19 10:07:51 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-01-22 12:03:21 +1100 |
commit | 2ecbad4e91192c88f831d8690dbad31ddba72135 (patch) | |
tree | 05700d7e5ba462c58b92885e72911c0d8e4465e8 /extmod/asyncio/core.py | |
parent | 51fbec2780b9c095c7eabdabab043c30dbb99d1d (diff) |
extmod/asyncio: Support gather of tasks that finish early.
Adds support to asyncio.gather() for the case that one or more (or all)
sub-tasks finish and/or raise an exception before the gather starts.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod/asyncio/core.py')
-rw-r--r-- | extmod/asyncio/core.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/extmod/asyncio/core.py b/extmod/asyncio/core.py index 214cc52f4..e5af3038f 100644 --- a/extmod/asyncio/core.py +++ b/extmod/asyncio/core.py @@ -219,6 +219,11 @@ def run_until_complete(main_task=None): elif t.state is None: # Task is already finished and nothing await'ed on the task, # so call the exception handler. + + # Save exception raised by the coro for later use. + t.data = exc + + # Create exception context and call the exception handler. _exc_context["exception"] = exc _exc_context["future"] = t Loop.call_exception_handler(_exc_context) |