Hrvoje Nikšić <hnik...@gmail.com> added the comment:

"""
At the moment this can be done but it will cancel all the coroutines with any 
exception that is raised and at some occasions this may not be desired.
"""

Does wait() really "cancel all the coroutines"? The documentation doesn't 
mention wait() canceling anything it only returns them in the `pending` set. It 
is gather() and wait_for() that cancel automatically.

If you want to cancel everything on some exception and not on another, you can 
easily implement the logic yourself, e.g:

tasks = [asyncio.ensure_future(example(x)) for x in range(20)]
done, pending = await asyncio.wait(tasks, return_when=FIRST_EXCEPTION)
for fut in done:
    try:
        fut.result()
    except CancelException:
        for fut in pending:
            fut.cancel()

----------
nosy: +hniksic

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33403>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to