1 |
commit: 4db210cf165f426f695ecf8307942a2610b352fc |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Aug 17 04:20:22 2020 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Aug 17 04:23:49 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=4db210cf |
7 |
|
8 |
async_iter_completed: check if loop is closed in finally clause |
9 |
|
10 |
This avoids RuntimeError('Event loop is closed') errors triggered |
11 |
by SIGINT. |
12 |
|
13 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
14 |
|
15 |
lib/portage/util/futures/iter_completed.py | 5 +++-- |
16 |
1 file changed, 3 insertions(+), 2 deletions(-) |
17 |
|
18 |
diff --git a/lib/portage/util/futures/iter_completed.py b/lib/portage/util/futures/iter_completed.py |
19 |
index 9554b4338..3c1a58e7e 100644 |
20 |
--- a/lib/portage/util/futures/iter_completed.py |
21 |
+++ b/lib/portage/util/futures/iter_completed.py |
22 |
@@ -107,8 +107,9 @@ def async_iter_completed(futures, max_jobs=None, max_load=None, loop=None): |
23 |
yield future_done_set |
24 |
finally: |
25 |
# cleanup in case of interruption by SIGINT, etc |
26 |
- scheduler.cancel() |
27 |
- scheduler.wait() |
28 |
+ if not loop.is_closed(): |
29 |
+ scheduler.cancel() |
30 |
+ scheduler.wait() |
31 |
|
32 |
|
33 |
def iter_gather(futures, max_jobs=None, max_load=None, loop=None): |