diff options
author | Damien George <damien@micropython.org> | 2024-01-23 11:11:25 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-01-23 11:13:35 +1100 |
commit | c3ca3612d1ef5e490045c3d4038b1362993c0f26 (patch) | |
tree | e4f0f9419cba177735cbff9c848e5a27d7bc3c7c /tests | |
parent | e111793d8d6a0b921f47c7396b70a0aca1edaea5 (diff) | |
download | micropython-c3ca3612d1ef5e490045c3d4038b1362993c0f26.tar.gz micropython-c3ca3612d1ef5e490045c3d4038b1362993c0f26.zip |
tests/extmod/asyncio_wait_task.py: Add test for raise and delayed wait.
This case was fixed in 2ecbad4e91192c88f831d8690dbad31ddba72135, which
stored the exception in the task object.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/extmod/asyncio_wait_task.py | 11 | ||||
-rw-r--r-- | tests/extmod/asyncio_wait_task.py.exp | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/extmod/asyncio_wait_task.py b/tests/extmod/asyncio_wait_task.py index bce426d971..7d79104f8c 100644 --- a/tests/extmod/asyncio_wait_task.py +++ b/tests/extmod/asyncio_wait_task.py @@ -68,5 +68,16 @@ async def main(): except ValueError: print("ValueError") + # Wait on a task that raises, but the waiting is done some time later. + # Need to suppress the "Task exception wasn't retrieved" message. + asyncio.get_event_loop().set_exception_handler(lambda loop, context: None) + t = asyncio.create_task(task_raise()) + for _ in range(5): + await asyncio.sleep(0) + try: + await t + except ValueError: + print("ValueError") + asyncio.run(main()) diff --git a/tests/extmod/asyncio_wait_task.py.exp b/tests/extmod/asyncio_wait_task.py.exp index 04be37f484..514a434223 100644 --- a/tests/extmod/asyncio_wait_task.py.exp +++ b/tests/extmod/asyncio_wait_task.py.exp @@ -8,3 +8,5 @@ world took 200 200 task_raise ValueError +task_raise +ValueError |