This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cjrh
Recipients aeros, asvetlov, cjrh, timmwagener, yselivanov
Date 2020-06-13.04:52:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1592023944.77.0.594453429219.issue40894@roundup.psfhosted.org>
In-reply-to
Content
Kyle is correct.  By analogy with Kyle's example, the following example has no gather, only two nested futures:

```
# childfut.py
import asyncio

async def f(fut):
    await fut

async def g(t):
    await asyncio.sleep(t)

async def main():
    fut_g = asyncio.create_task(g(1))
    fut_f = asyncio.create_task(f(fut_g))

    try:

        # Cancel the "child" future
        fut_g.cancel()

        await fut_f
    except asyncio.CancelledError as e:
        pass

    print(f'fut_f done? {fut_f.done()} fut_f cancelled? {fut_f.cancelled()}')
    print(f'fut_g done? {fut_g.done()} fut_g cancelled? {fut_g.cancelled()}')

asyncio.run(main())
```

It produces:

```
$ python childfut.py
fut_f done? True fut_f cancelled? True
fut_g done? True fut_g cancelled? True
```

The outer future f, has f.cancelled() == True even though it was the inner future got cancelled.

I think `gather()` should work the same. It would be confusing if `future_gather.cancelled()` is false if a child is cancelled, while a plain old outer future returns `future.cancelled() == true` if futures that it waits on are cancelled.
History
Date User Action Args
2020-06-13 04:52:24cjrhsetrecipients: + cjrh, asvetlov, yselivanov, aeros, timmwagener
2020-06-13 04:52:24cjrhsetmessageid: <1592023944.77.0.594453429219.issue40894@roundup.psfhosted.org>
2020-06-13 04:52:24cjrhlinkissue40894 messages
2020-06-13 04:52:24cjrhcreate