Message302079
If you do not await gather, then if one of gather inner coroutines fails, others keep working, but they should not.
```python
import asyncio
import logging
logging.basicConfig(level=logging.DEBUG)
loop = asyncio.get_event_loop()
async def success_coro(seconds):
await asyncio.sleep(seconds)
print(seconds)
async def failed_coro(seconds):
await asyncio.sleep(seconds)
print(seconds)
raise ZeroDivisionError
coros = [
success_coro(2),
failed_coro(3),
success_coro(5),
]
async def waiter():
await asyncio.gather(*coros)
asyncio.ensure_future(waiter())
loop.run_forever()
```
-------------------------------------------------------------
Console:
2
3
ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<waiter() done, defined at tst.py:72> exception=ZeroDivisionError()>
Traceback (most recent call last):
File "tst.py", line 73, in waiter
await asyncio.gather(*coros)
File "tst.py", line 64, in failed_coro
raise ZeroDivisionError
ZeroDivisionError
5
-------------------------------------------------------------
Expected behavior that 5 should not be printed. |
|
Date |
User |
Action |
Args |
2017-09-13 14:53:37 | Andrew Lytvyn | set | recipients:
+ Andrew Lytvyn, asvetlov, yselivanov |
2017-09-13 14:53:37 | Andrew Lytvyn | set | messageid: <1505314417.04.0.216091950997.issue31452@psf.upfronthosting.co.za> |
2017-09-13 14:53:36 | Andrew Lytvyn | link | issue31452 messages |
2017-09-13 14:53:36 | Andrew Lytvyn | create | |
|