Skip to content

Commit 7235c20

Browse files
committed
add test for create_task() following cancel()
1 parent 8345647 commit 7235c20

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Lib/test/test_asyncio/test_taskgroups.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,14 @@ async def test_taskgroup_cancel_before_enter(self):
10411041
count += 1
10421042
self.assertEqual(count, 1)
10431043

1044+
async def test_taskgroup_cancel_before_create_task(self):
1045+
async with asyncio.TaskGroup() as tg:
1046+
tg.cancel()
1047+
# TODO: This behavior is not ideal. We'd rather have no exception
1048+
# raised, and the child task run until the first await.
1049+
with self.assertRaises(RuntimeError):
1050+
tg.create_task(asyncio.sleep(1))
1051+
10441052
async def test_taskgroup_cancel_before_exception(self):
10451053
async def raise_exc(parent_tg: asyncio.TaskGroup):
10461054
parent_tg.cancel()

0 commit comments

Comments
 (0)