1 |
commit: 2f474767eaf3b042bea31bc524281e0841cb271b |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Sep 20 06:44:36 2021 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Sep 20 07:07:22 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=2f474767 |
7 |
|
8 |
ExtendedFuture: 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/extendedfutures.py | 24 +++++++++++++++++++++--- |
15 |
1 file changed, 21 insertions(+), 3 deletions(-) |
16 |
|
17 |
diff --git a/lib/portage/util/futures/extendedfutures.py b/lib/portage/util/futures/extendedfutures.py |
18 |
index 6aa3ebbe8..c23feafb5 100644 |
19 |
--- a/lib/portage/util/futures/extendedfutures.py |
20 |
+++ b/lib/portage/util/futures/extendedfutures.py |
21 |
@@ -10,7 +10,13 @@ __all__ = ( |
22 |
"InvalidStateError", |
23 |
) |
24 |
|
25 |
-from portage.util.futures.futures import Future, InvalidStateError, CancelledError |
26 |
+import concurrent.futures |
27 |
+from concurrent.futures import Future, CancelledError |
28 |
+ |
29 |
+try: |
30 |
+ from concurrent.futures import InvalidStateError |
31 |
+except ImportError: |
32 |
+ from portage.util.futures.futures import InvalidStateError |
33 |
|
34 |
# Create our one time settable unset constant |
35 |
UNSET_CONST = Future() |
36 |
@@ -62,9 +68,21 @@ class ExtendedFuture(Future): |
37 |
default = self.default_result |
38 |
if default is not UNSET_CONST.result(): |
39 |
try: |
40 |
- data = super(ExtendedFuture, self).result() |
41 |
+ data = self.result() |
42 |
except InvalidStateError: |
43 |
data = default |
44 |
else: |
45 |
- data = super(ExtendedFuture, self).result() |
46 |
+ data = self.result() |
47 |
return data |
48 |
+ |
49 |
+ def exception(self): |
50 |
+ try: |
51 |
+ return super(ExtendedFuture, self).exception(timeout=0) |
52 |
+ except concurrent.futures.TimeoutError: |
53 |
+ raise InvalidStateError |
54 |
+ |
55 |
+ def result(self): |
56 |
+ try: |
57 |
+ return super(ExtendedFuture, self).result(timeout=0) |
58 |
+ except concurrent.futures.TimeoutError: |
59 |
+ raise InvalidStateError |