Skip to content
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

Remove redundant _ensure_future in favor of ensure_future in asyncio #102398

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Changes from all commits
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
8 changes: 2 additions & 6 deletions Lib/asyncio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,6 @@ def ensure_future(coro_or_future, *, loop=None):

If the argument is a Future, it is returned directly.
"""
return _ensure_future(coro_or_future, loop=loop)


def _ensure_future(coro_or_future, *, loop=None):
if futures.isfuture(coro_or_future):
if loop is not None and loop is not futures._get_loop(coro_or_future):
raise ValueError('The future belongs to a different loop than '
Expand Down Expand Up @@ -798,7 +794,7 @@ def _done_callback(fut):
outer = None # bpo-46672
for arg in coros_or_futures:
if arg not in arg_to_fut:
fut = _ensure_future(arg, loop=loop)
fut = ensure_future(arg, loop=loop)
if loop is None:
loop = futures._get_loop(fut)
if fut is not arg:
Expand Down Expand Up @@ -855,7 +851,7 @@ def shield(arg):
weak references to tasks. A task that isn't referenced elsewhere
may get garbage collected at any time, even before it's done.
"""
inner = _ensure_future(arg)
inner = ensure_future(arg)
if inner.done():
# Shortcut.
return inner
Expand Down