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
Revert mistaken changes.
  • Loading branch information
Dreamsorcerer authored Dec 15, 2021
commit c6941733a7200d0a3bc4f18b8bf4567f18a0795a
14 changes: 3 additions & 11 deletions Lib/asyncio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def _release_waiter(waiter, *args):
waiter.set_result(None)


async def wait_for(fut, timeout, *, loop=None):
async def wait_for(fut, timeout):
"""Wait for the single Future or coroutine to complete, with timeout.

Coroutine will be wrapped in Task.
Expand All @@ -402,12 +402,7 @@ async def wait_for(fut, timeout, *, loop=None):

This function is a coroutine.
"""
if loop is None:
loop = events.get_running_loop()
else:
warnings.warn("The loop argument is deprecated since Python 3.8, "
"and scheduled for removal in Python 3.10.",
DeprecationWarning, stacklevel=2)
loop = events.get_running_loop()

if timeout is None:
return await fut
Expand All @@ -426,10 +421,7 @@ async def wait_for(fut, timeout, *, loop=None):

waiter = loop.create_future()
timeout_handle = loop.call_later(timeout, _release_waiter, waiter)
#cb = functools.partial(_release_waiter, waiter)

def cb(f):
_release_waiter(waiter)
cb = functools.partial(_release_waiter, waiter)

fut = ensure_future(fut, loop=loop)
fut.add_done_callback(cb)
Expand Down
0