Closed
Description
This is easy to explain, cancelling a gather(...) will only cancel one task, the remaining ones still continue.
Testcase:
async def test_gather_cancel_itself():
res = []
async def consumer():
nonlocal res
try:
await asyncio.sleep(1)
except asyncio.CancelledError:
dprint("wait() cancelled")
res.append(True)
else:
res.append(False)
async def gather():
t = []
for _ in range(5):
t.append(asyncio.create_task(consumer()))
try:
await asyncio.gather(*t)
except asyncio.CancelledError:
print("gather cancelled")
t = asyncio.create_task(gather())
await asyncio.sleep(0.1)
t.cancel()
await asyncio.sleep(1.5)
return res