8000 bpo-42130: Fix for explicit suppressing of cancellations in wait_for() by Dreamsorcerer · Pull Request #28149 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-42130: Fix for explicit suppressing of cancellations in wait_for() #28149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into patch-4
  • Loading branch information
Dreamsorcerer authored Nov 29, 2021
commit 80f027b5a604c216fb180feb7020b9acfdf99183
9 changes: 5 additions & 4 deletions Lib/test/test_asyncio/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,15 +1010,16 @@ def gen():

def test_wait_for_cancellation_race_condition(self):
async def inner():
await asyncio.wait_for(asyncio.sleep(1), timeout=2)
with contextlib.suppress(asyncio.CancelledError):
await asyncio.sleep(1)
return 1

async def main():
result = await asyncio.wait_for(inner(), timeout=1)
result = await asyncio.wait_for(inner(), timeout=.01)
assert result == 1

asyncio.run(main())

def test_wait_for_does_not_suppress_cancellation(self):
async def inner():
return
Expand All @@ -1034,7 +1035,7 @@ async def main():
task.cancel()
with self.assertRaises(asyncio.CancelledError):
await task

asyncio.run(main())

def test_wait_for_waits_for_task_cancellation(self):
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0