FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-157157: Make test_taskgroup_cancel_keeps_outer_cancellation deterministic by iamsharduld · Pull Request #157158 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
11 changes: 9 additions & 2 deletions Lib/test/test_asyncio/test_taskgroups.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1200,11 +1200,17 @@ async def child(tg):

async def test_taskgroup_cancel_keeps_outer_cancellation(self):
# gh-155433: any cancellation from outside the group must propagate.
cancelling = asyncio.Event()
release = asyncio.Event()

async def child():
try:
await asyncio.sleep(10)
finally:
await asyncio.sleep(0.1)
# The group is cancelling: it has cancelled its parent task
# and is waiting for this task to finish.
cancelling.set()
await release.wait()

async def body():
async with asyncio.TaskGroup() as tg:
Expand All @@ -1213,8 +1219,9 @@ async def body():
tg.cancel()

task = asyncio.create_task(body())
await asyncio.sleep(0.01)
await cancelling.wait()
task.cancel('message')
release.set()
with self.assertRaises(asyncio.CancelledError) as cm:
await task
self.assertEqual('message', cm.exception.args[0])
Expand Down
Loading

Back | FazBrowse Home | New Git URL