commit:     64b11fe4dbcd7f2b4c36d8c40a09425a2c624c7a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 29 04:24:19 2020 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb 29 04:31:50 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=64b11fe4

asyncio: improve _AsyncioEventLoop isinstance logic

Since _AsyncioEventLoop can be wrapped, use the _asyncio_wrapper
attributre for isinstance checks (_wrap_loop guarantees that this
attribute exists).

Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/util/futures/_asyncio/__init__.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/portage/util/futures/_asyncio/__init__.py 
b/lib/portage/util/futures/_asyncio/__init__.py
index 7635dbb5e..f4b03891f 100644
--- a/lib/portage/util/futures/_asyncio/__init__.py
+++ b/lib/portage/util/futures/_asyncio/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2018 Gentoo Foundation
+# Copyright 2018-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = (
@@ -139,7 +139,7 @@ def create_subprocess_exec(*args, **kwargs):
        """
        loop = _wrap_loop(kwargs.pop('loop', None))
        kwargs.setdefault('close_fds', _close_fds_default)
-       if _asyncio_enabled and isinstance(loop, _AsyncioEventLoop):
+       if _asyncio_enabled and isinstance(loop._asyncio_wrapper, 
_AsyncioEventLoop):
                # Use the real asyncio create_subprocess_exec (loop argument
                # is deprecated since since Python 3.8).
                return _real_asyncio.create_subprocess_exec(*args, **kwargs)
@@ -191,10 +191,10 @@ def ensure_future(coro_or_future, loop=None):
        @return: an instance of Future
        """
        loop = _wrap_loop(loop)
-       if _asyncio_enabled and isinstance(loop, _AsyncioEventLoop):
+       if _asyncio_enabled and isinstance(loop._asyncio_wrapper, 
_AsyncioEventLoop):
                # Use the real asyncio loop and ensure_future.
                return _real_asyncio.ensure_future(
-                       coro_or_future, loop=loop._loop)
+                       coro_or_future, loop=loop._asyncio_wrapper._loop)
 
        if isinstance(coro_or_future, Future):
                return coro_or_future

Reply via email to