Caleb Hattingh <caleb.hatti...@gmail.com> added the comment:

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.

----------
nosy: +cjrh

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

Reply via email to