1 |
commit: 64b11fe4dbcd7f2b4c36d8c40a09425a2c624c7a |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Feb 29 04:24:19 2020 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Feb 29 04:31:50 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=64b11fe4 |
7 |
|
8 |
asyncio: improve _AsyncioEventLoop isinstance logic |
9 |
|
10 |
Since _AsyncioEventLoop can be wrapped, use the _asyncio_wrapper |
11 |
attributre for isinstance checks (_wrap_loop guarantees that this |
12 |
attribute exists). |
13 |
|
14 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
15 |
|
16 |
lib/portage/util/futures/_asyncio/__init__.py | 8 ++++---- |
17 |
1 file changed, 4 insertions(+), 4 deletions(-) |
18 |
|
19 |
diff --git a/lib/portage/util/futures/_asyncio/__init__.py b/lib/portage/util/futures/_asyncio/__init__.py |
20 |
index 7635dbb5e..f4b03891f 100644 |
21 |
--- a/lib/portage/util/futures/_asyncio/__init__.py |
22 |
+++ b/lib/portage/util/futures/_asyncio/__init__.py |
23 |
@@ -1,4 +1,4 @@ |
24 |
-# Copyright 2018 Gentoo Foundation |
25 |
+# Copyright 2018-2020 Gentoo Authors |
26 |
# Distributed under the terms of the GNU General Public License v2 |
27 |
|
28 |
__all__ = ( |
29 |
@@ -139,7 +139,7 @@ def create_subprocess_exec(*args, **kwargs): |
30 |
""" |
31 |
loop = _wrap_loop(kwargs.pop('loop', None)) |
32 |
kwargs.setdefault('close_fds', _close_fds_default) |
33 |
- if _asyncio_enabled and isinstance(loop, _AsyncioEventLoop): |
34 |
+ if _asyncio_enabled and isinstance(loop._asyncio_wrapper, _AsyncioEventLoop): |
35 |
# Use the real asyncio create_subprocess_exec (loop argument |
36 |
# is deprecated since since Python 3.8). |
37 |
return _real_asyncio.create_subprocess_exec(*args, **kwargs) |
38 |
@@ -191,10 +191,10 @@ def ensure_future(coro_or_future, loop=None): |
39 |
@return: an instance of Future |
40 |
""" |
41 |
loop = _wrap_loop(loop) |
42 |
- if _asyncio_enabled and isinstance(loop, _AsyncioEventLoop): |
43 |
+ if _asyncio_enabled and isinstance(loop._asyncio_wrapper, _AsyncioEventLoop): |
44 |
# Use the real asyncio loop and ensure_future. |
45 |
return _real_asyncio.ensure_future( |
46 |
- coro_or_future, loop=loop._loop) |
47 |
+ coro_or_future, loop=loop._asyncio_wrapper._loop) |
48 |
|
49 |
if isinstance(coro_or_future, Future): |
50 |
return coro_or_future |