-
-
Notifications
You must be signed in to change notification settings - Fork 178
implementation of asyncio.wait waiting for iterator is not complete #461
Comments
Actually, import asyncio
async def task1():
await asyncio.sleep(3)
raise RuntimeError
async def task2():
await asyncio.sleep(10)
async def main():
tasks = [task1(), task2()]
done, pending = await asyncio.wait(tasks, return_when='FIRST_COMPLETED')
exception = done.pop().exception()
assert isinstance(exception, RuntimeError)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close() |
@005 I'd be interested in the actual code that caused this suggestion. |
it looks its not asyncio, but something esle. here is the simplest example i could come up with. notice there are 2 urls that server will handle /1 open each one in different browser tab, and then there will be a difference
|
asyncio.wait has 3 different options to run with
Constant Description
FIRST_COMPLETED The function will return when any future finishes or is cancelled.
FIRST_EXCEPTION The function will return when any future finishes by raising an exception. If no future raises an exception then it is equivalent to ALL_COMPLETED.
ALL_COMPLETED The function will return when all futures finish or are cancelled.
but there is no way to run it in 4-th mode FIRST_COMPLETED + FIRST_EXCEPTION
which is "must-have" in the case when it suppose to wait for iterator
it will send totally legit Exception about end of iteration
but asyncio.wait has no way to catch/handle it properly.
The text was updated successfully, but these errors were encountered: