Skip to content

Commit 0dcc98d

Browse files
Add a regression guard for the gather() done callback
Co-authored-by: Leandro Damascena <leandro.damascena@gmail.com>
1 parent af8a20c commit 0dcc98d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎Lib/test/test_asyncio/test_tasks.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,19 @@ async def coro():
12681268

12691269
self.loop.run_until_complete(self.new_task(self.loop, coro()))
12701270

1271+
def test_gather_does_not_add_callback_to_outer(self):
1272+
# gh-158239: gather() must not add an internal done callback to
1273+
# the outer future just to maintain the await graph.
1274+
async def child():
1275+
await asyncio.sleep(0)
1276+
1277+
async def coro():
1278+
outer = asyncio.gather(child(), child())
1279+
self.assertFalse(outer._callbacks)
1280+
await outer
1281+
1282+
self.loop.run_until_complete(self.new_task(self.loop, coro()))
1283+
12711284
def test_wait_really_done(self):
12721285
# there is possibility that some tasks in the pending list
12731286
# became done but their callbacks haven't all been called yet

0 commit comments

Comments
 (0)