Skip to content

Commit c3ca361

Browse files
committed
tests/extmod/asyncio_wait_task.py: Add test for raise and delayed wait.
This case was fixed in 2ecbad4, which stored the exception in the task object. Signed-off-by: Damien George <[email protected]>
1 parent e111793 commit c3ca361

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tests/extmod/asyncio_wait_task.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,16 @@ async def main():
6868
except ValueError:
6969
print("ValueError")
7070

71+
# Wait on a task that raises, but the waiting is done some time later.
72+
# Need to suppress the "Task exception wasn't retrieved" message.
73+
asyncio.get_event_loop().set_exception_handler(lambda loop, context: None)
74+
t = asyncio.create_task(task_raise())
75+
for _ in range(5):
76+
await asyncio.sleep(0)
77+
try:
78+
await t
79+
except ValueError:
80+
print("ValueError")
81+
7182

7283
asyncio.run(main())

tests/extmod/asyncio_wait_task.py.exp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ world
88
took 200 200
99
task_raise
1010
ValueError
11+
task_raise
12+
ValueError

0 commit comments

Comments
 (0)