1 |
commit: 631bedffe29124d693de3b539fc908d9feec1420 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Sep 20 05:05:38 2021 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Sep 20 05:08:47 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=631bedff |
7 |
|
8 |
_safe_loop: fix python3.10 DeprecationWarning |
9 |
|
10 |
DeprecationWarning: There is no current event loop |
11 |
|
12 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
13 |
|
14 |
lib/portage/util/futures/_asyncio/__init__.py | 10 +++++++--- |
15 |
1 file changed, 7 insertions(+), 3 deletions(-) |
16 |
|
17 |
diff --git a/lib/portage/util/futures/_asyncio/__init__.py b/lib/portage/util/futures/_asyncio/__init__.py |
18 |
index c1229528a..ccf800c66 100644 |
19 |
--- a/lib/portage/util/futures/_asyncio/__init__.py |
20 |
+++ b/lib/portage/util/futures/_asyncio/__init__.py |
21 |
@@ -280,10 +280,14 @@ def _safe_loop(): |
22 |
loop = _thread_weakrefs.loops[thread_key] |
23 |
except KeyError: |
24 |
try: |
25 |
- _real_asyncio.get_event_loop() |
26 |
+ try: |
27 |
+ _loop = _real_asyncio.get_running_loop() |
28 |
+ except AttributeError: |
29 |
+ _loop = _real_asyncio.get_event_loop() |
30 |
except RuntimeError: |
31 |
- _real_asyncio.set_event_loop(_real_asyncio.new_event_loop()) |
32 |
- loop = _thread_weakrefs.loops[thread_key] = _AsyncioEventLoop() |
33 |
+ _loop = _real_asyncio.new_event_loop() |
34 |
+ _real_asyncio.set_event_loop(_loop) |
35 |
+ loop = _thread_weakrefs.loops[thread_key] = _AsyncioEventLoop(loop=_loop) |
36 |
|
37 |
if ( |
38 |
_thread_weakrefs.mainloop is None |