1 |
commit: 05c2708f45c951978a76cc897ca58b7a6f79c533 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Mar 2 01:43:23 2020 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Mar 2 03:29:57 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=05c2708f |
7 |
|
8 |
Subprocess: delay unregister in _async_wait (bug 711174) |
9 |
|
10 |
Since the super class AbstractPollTask _async_wait method |
11 |
calls _unregister, it can trigger premature _unregister before |
12 |
pid status is available. Therefore, only call the super class |
13 |
_async_wait method after pid status is available. This should |
14 |
help prevent premature _unregister events that trigger reading |
15 |
of build logs before they're closed as in bug 658806 and |
16 |
bug 711174. |
17 |
|
18 |
Bug: https://bugs.gentoo.org/711174 |
19 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
20 |
|
21 |
lib/_emerge/SubProcess.py | 11 ++++++++++- |
22 |
1 file changed, 10 insertions(+), 1 deletion(-) |
23 |
|
24 |
diff --git a/lib/_emerge/SubProcess.py b/lib/_emerge/SubProcess.py |
25 |
index 7d6b03272..1ddfe57fd 100644 |
26 |
--- a/lib/_emerge/SubProcess.py |
27 |
+++ b/lib/_emerge/SubProcess.py |
28 |
@@ -1,10 +1,11 @@ |
29 |
-# Copyright 1999-2018 Gentoo Foundation |
30 |
+# Copyright 1999-2020 Gentoo Authors |
31 |
# Distributed under the terms of the GNU General Public License v2 |
32 |
|
33 |
import logging |
34 |
|
35 |
from portage import os |
36 |
from portage.util import writemsg_level |
37 |
+from portage.util.futures import asyncio |
38 |
from _emerge.AbstractPollTask import AbstractPollTask |
39 |
import signal |
40 |
import errno |
41 |
@@ -40,6 +41,14 @@ class SubProcess(AbstractPollTask): |
42 |
return self.pid is not None and \ |
43 |
self.returncode is None |
44 |
|
45 |
+ def _async_wait(self): |
46 |
+ if self.returncode is None: |
47 |
+ raise asyncio.InvalidStateError('Result is not ready for %s' % (self,)) |
48 |
+ else: |
49 |
+ # This calls _unregister, so don't call it until pid status |
50 |
+ # is available. |
51 |
+ super(SubProcess, self)._async_wait() |
52 |
+ |
53 |
def _async_waitpid(self): |
54 |
""" |
55 |
Wait for exit status of self.pid asynchronously, and then |