commit: e50db212f0bf748b72150ebb67ceee065d73462e Author: Zac Medico <zmedico <AT> gentoo <DOT> org> AuthorDate: Sat Nov 22 20:12:14 2025 +0000 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> CommitDate: Thu Nov 27 05:16:24 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e50db212
_sync_decorator.py: Replace lazyimport with function local import Bug: https://bugs.gentoo.org/951146 Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> lib/portage/util/futures/_sync_decorator.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/portage/util/futures/_sync_decorator.py b/lib/portage/util/futures/_sync_decorator.py index 436e7c3462..6c1639d061 100644 --- a/lib/portage/util/futures/_sync_decorator.py +++ b/lib/portage/util/futures/_sync_decorator.py @@ -1,14 +1,9 @@ -# Copyright 2018-2021 Gentoo Authors +# Copyright 2018-2025 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import functools -import portage - -portage.proxy.lazyimport.lazyimport( - globals(), - "portage.util.futures:asyncio", -) +from portage.proxy.objectproxy import ObjectProxy def _sync_decorator(func, loop=None): @@ -20,6 +15,8 @@ def _sync_decorator(func, loop=None): @functools.wraps(func) def wrapper(*args, **kwargs): + from portage.util.futures import asyncio + return (loop or asyncio.get_event_loop()).run_until_complete( func(*args, **kwargs) ) @@ -36,6 +33,8 @@ def _sync_methods(obj, loop=None): code, eliminating clutter that might otherwise discourage the proliferation of coroutine usage for I/O bound tasks. """ + from portage.util.futures import asyncio + loop = asyncio._wrap_loop(loop) return _ObjectAttrWrapper( obj, @@ -47,7 +46,7 @@ def _sync_methods(obj, loop=None): ) -class _ObjectAttrWrapper(portage.proxy.objectproxy.ObjectProxy): +class _ObjectAttrWrapper(ObjectProxy): __slots__ = ("_obj", "_attr_wrapper") def __init__(self, obj, attr_wrapper):
