Message371436
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. |
|
Date |
User |
Action |
Args |
2020-06-13 04:52:24 | cjrh | set | recipients:
+ cjrh, asvetlov, yselivanov, aeros, timmwagener |
2020-06-13 04:52:24 | cjrh | set | messageid: <1592023944.77.0.594453429219.issue40894@roundup.psfhosted.org> |
2020-06-13 04:52:24 | cjrh | link | issue40894 messages |
2020-06-13 04:52:24 | cjrh | create | |
|