kopia lustrzana https://github.com/micropython/micropython
tests/extmod/asyncio_wait_task.py: Add test for raise and delayed wait.
This case was fixed in 2ecbad4e91
, which
stored the exception in the task object.
Signed-off-by: Damien George <damien@micropython.org>
pull/11847/head
rodzic
e111793d8d
commit
c3ca3612d1
|
@ -68,5 +68,16 @@ async def main():
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print("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())
|
asyncio.run(main())
|
||||||
|
|
|
@ -8,3 +8,5 @@ world
|
||||||
took 200 200
|
took 200 200
|
||||||
task_raise
|
task_raise
|
||||||
ValueError
|
ValueError
|
||||||
|
task_raise
|
||||||
|
ValueError
|
||||||
|
|
Ładowanie…
Reference in New Issue