mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Remove redundant _ensure_future
in favor of ensure_future
in asyncio
(#102398)
This commit is contained in:
parent
80b19a30c0
commit
d8485d6c8b
1 changed files with 2 additions and 6 deletions
|
@ -630,10 +630,6 @@ def ensure_future(coro_or_future, *, loop=None):
|
||||||
|
|
||||||
If the argument is a Future, it is returned directly.
|
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 futures.isfuture(coro_or_future):
|
||||||
if loop is not None and loop is not futures._get_loop(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 '
|
raise ValueError('The future belongs to a different loop than '
|
||||||
|
@ -798,7 +794,7 @@ def gather(*coros_or_futures, return_exceptions=False):
|
||||||
outer = None # bpo-46672
|
outer = None # bpo-46672
|
||||||
for arg in coros_or_futures:
|
for arg in coros_or_futures:
|
||||||
if arg not in arg_to_fut:
|
if arg not in arg_to_fut:
|
||||||
fut = _ensure_future(arg, loop=loop)
|
fut = ensure_future(arg, loop=loop)
|
||||||
if loop is None:
|
if loop is None:
|
||||||
loop = futures._get_loop(fut)
|
loop = futures._get_loop(fut)
|
||||||
if fut is not arg:
|
if fut is not arg:
|
||||||
|
@ -855,7 +851,7 @@ def shield(arg):
|
||||||
weak references to tasks. A task that isn't referenced elsewhere
|
weak references to tasks. A task that isn't referenced elsewhere
|
||||||
may get garbage collected at any time, even before it's done.
|
may get garbage collected at any time, even before it's done.
|
||||||
"""
|
"""
|
||||||
inner = _ensure_future(arg)
|
inner = ensure_future(arg)
|
||||||
if inner.done():
|
if inner.done():
|
||||||
# Shortcut.
|
# Shortcut.
|
||||||
return inner
|
return inner
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue