8000 bpo-32751: Wait for task cancellation in asyncio.wait_for() by elprans · Pull Request #7216 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-32751: Wait for task cancellation in asyncio.wait_for() #7216

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

Merged
merged 3 commits into from
May 29, 2018
Merged
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
Move fut.cancel() inside exception block
  • Loading branch information
elprans committed May 29, 2018
commit 36fe427c79a4086914b2b64889f72b8155c6037e
2 changes: 1 addition & 1 deletion Lib/asyncio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ async def _cancel_and_wait(fut, loop):
waiter = loop.create_future()
cb = functools.partial(_release_waiter, waiter)
fut.add_done_callback(cb)
fut.cancel()

try:
fut.cancel()
# We cannot wait on *fut* directly to make
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice trick!

# sure _cancel_and_wait itself is reliably cancellable.
await waiter
Expand Down
0