From 7f6b2b04878209130d44fc06105f521bae2b2173 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 30 Aug 2024 22:35:32 -0700 Subject: asyncio: Use default sleep implementation when possible When a loop argument is not given, use the default asyncio sleep implementation and avoid unnecessary _wrap_loop usage. Bug: https://bugs.gentoo.org/761538 Signed-off-by: Zac Medico --- lib/portage/util/futures/_asyncio/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/portage/util/futures/_asyncio/__init__.py b/lib/portage/util/futures/_asyncio/__init__.py index 23c664e76..a235d8724 100644 --- a/lib/portage/util/futures/_asyncio/__init__.py +++ b/lib/portage/util/futures/_asyncio/__init__.py @@ -210,9 +210,12 @@ def sleep(delay, result=None, loop=None): @param result: result of the future @type loop: asyncio.AbstractEventLoop (or compatible) @param loop: event loop - @rtype: asyncio.Future (or compatible) - @return: an instance of Future + @rtype: collections.abc.Coroutine or asyncio.Future + @return: an instance of Coroutine or Future """ + if loop is None: + return _real_asyncio.sleep(delay, result=result) + loop = _wrap_loop(loop) future = loop.create_future() handle = loop.call_later(delay, future.set_result, result) -- cgit v1.2.3-65-gdbad