Author hniksic
Recipients asvetlov, giampaolo.rodola, hniksic, pyneda, yselivanov
Date 2018-05-16.20:49:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1526503749.67.0.682650639539.issue33403@psf.upfronthosting.co.za>
In-reply-to
Content
"""
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()
History
Date User Action Args
2018-05-16 20:49:09hniksicsetrecipients: + hniksic, giampaolo.rodola, asvetlov, yselivanov, pyneda
2018-05-16 20:49:09hniksicsetmessageid: <1526503749.67.0.682650639539.issue33403@psf.upfronthosting.co.za>
2018-05-16 20:49:09hniksiclinkissue33403 messages
2018-05-16 20:49:09hniksiccreate