1 |
Make the _safe_loop function an alias for the global_event_loop |
2 |
function, so that the default asyncio event loop implementation |
3 |
will be used in API consumer threads. This is possible because |
4 |
global_event_loop has been fixed (bug 758740) to always use |
5 |
AsyncioEventLoop, and that uses asyncio.get_event_loop() which |
6 |
returns a new event loop for each thread. |
7 |
|
8 |
Bug: https://bugs.gentoo.org/758755 |
9 |
Signed-off-by: Zac Medico <zmedico@g.o> |
10 |
--- |
11 |
lib/portage/util/futures/_asyncio/__init__.py | 17 +---------------- |
12 |
1 file changed, 1 insertion(+), 16 deletions(-) |
13 |
|
14 |
diff --git a/lib/portage/util/futures/_asyncio/__init__.py b/lib/portage/util/futures/_asyncio/__init__.py |
15 |
index a902ad895..ce3685709 100644 |
16 |
--- a/lib/portage/util/futures/_asyncio/__init__.py |
17 |
+++ b/lib/portage/util/futures/_asyncio/__init__.py |
18 |
@@ -39,6 +39,7 @@ portage.proxy.lazyimport.lazyimport(globals(), |
19 |
from portage.util._eventloop.asyncio_event_loop import AsyncioEventLoop as _AsyncioEventLoop |
20 |
from portage.util._eventloop.global_event_loop import ( |
21 |
global_event_loop as _global_event_loop, |
22 |
+ global_event_loop as _safe_loop, |
23 |
) |
24 |
# pylint: disable=redefined-builtin |
25 |
from portage.util.futures.futures import ( |
26 |
@@ -241,19 +242,3 @@ def _wrap_loop(loop=None): |
27 |
loop = loop or _global_event_loop() |
28 |
return (loop if hasattr(loop, '_asyncio_wrapper') |
29 |
else _AsyncioEventLoop(loop=loop)) |
30 |
- |
31 |
- |
32 |
-def _safe_loop(): |
33 |
- """ |
34 |
- Return an event loop that's safe to use within the current context. |
35 |
- For portage internal callers, this returns a globally shared event |
36 |
- loop instance. For external API consumers, this constructs a |
37 |
- temporary event loop instance that's safe to use in a non-main |
38 |
- thread (it does not override the global SIGCHLD handler). |
39 |
- |
40 |
- @rtype: asyncio.AbstractEventLoop (or compatible) |
41 |
- @return: event loop instance |
42 |
- """ |
43 |
- if portage._internal_caller: |
44 |
- return _global_event_loop() |
45 |
- return _EventLoop(main=False) |
46 |
-- |
47 |
2.26.2 |