diff options
author | Zac Medico <zmedico@gentoo.org> | 2024-08-31 10:32:12 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2024-08-31 23:59:34 -0700 |
commit | e5457915f7929db3781ded384bdb089b0760221f (patch) | |
tree | a35ac0c13c9554046c6feaa556a73dd5314e6aab | |
parent | asyncio: Use default sleep implementation when possible (diff) | |
download | portage-e5457915f7929db3781ded384bdb089b0760221f.tar.gz portage-e5457915f7929db3781ded384bdb089b0760221f.tar.bz2 portage-e5457915f7929db3781ded384bdb089b0760221f.zip |
asyncio: Use default ensure_future implementation when possible
When a loop argument is not given, use the default asyncio
ensure_future implementation and avoid unnecessary _wrap_loop
usage.
Bug: https://bugs.gentoo.org/761538
Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r-- | lib/portage/util/futures/_asyncio/__init__.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/portage/util/futures/_asyncio/__init__.py b/lib/portage/util/futures/_asyncio/__init__.py index a235d8724..48d9b6810 100644 --- a/lib/portage/util/futures/_asyncio/__init__.py +++ b/lib/portage/util/futures/_asyncio/__init__.py @@ -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. |