Skip to content

Commit

Permalink
asyncio: Use default ensure_future implementation when possible
Browse files Browse the repository at this point in the history
When a loop argument is not given, use the default asyncio
ensure_future implementation and avoid unnecessary _wrap_loop
usage.

Signed-off-by: Zac Medico <zmedico@gentoo.org>
  • Loading branch information
zmedico committed Aug 31, 2024
1 parent ab58647 commit 9836719
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/portage/util/futures/_asyncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ def ensure_future(coro_or_future, loop=None):
@rtype: asyncio.Future (or compatible)
@return: an instance of Future
"""
if loop is None:
return _real_asyncio.ensure_future(coro_or_future)

loop = _wrap_loop(loop)
if isinstance(loop._asyncio_wrapper, _AsyncioEventLoop):
# Use the real asyncio loop and ensure_future.
Expand Down

0 comments on commit 9836719

Please sign in to comment.