aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2020-03-01 17:43:23 -0800
committerZac Medico <zmedico@gentoo.org>2020-03-01 19:29:57 -0800
commit05c2708f45c951978a76cc897ca58b7a6f79c533 (patch)
tree5a6a255153d2addb1f671c92f60b8c4cb2ca3122 /lib/_emerge
parent_GeneratorTask: throw CancelledError in cancelled coroutine (bug 711174) (diff)
downloadportage-05c2708f45c951978a76cc897ca58b7a6f79c533.tar.gz
portage-05c2708f45c951978a76cc897ca58b7a6f79c533.tar.bz2
portage-05c2708f45c951978a76cc897ca58b7a6f79c533.zip
Subprocess: delay unregister in _async_wait (bug 711174)
Since the super class AbstractPollTask _async_wait method calls _unregister, it can trigger premature _unregister before pid status is available. Therefore, only call the super class _async_wait method after pid status is available. This should help prevent premature _unregister events that trigger reading of build logs before they're closed as in bug 658806 and bug 711174. Bug: https://bugs.gentoo.org/711174 Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib/_emerge')
-rw-r--r--lib/_emerge/SubProcess.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/_emerge/SubProcess.py b/lib/_emerge/SubProcess.py
index 7d6b03272..1ddfe57fd 100644
--- a/lib/_emerge/SubProcess.py
+++ b/lib/_emerge/SubProcess.py
@@ -1,10 +1,11 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import logging
from portage import os
from portage.util import writemsg_level
+from portage.util.futures import asyncio
from _emerge.AbstractPollTask import AbstractPollTask
import signal
import errno
@@ -40,6 +41,14 @@ class SubProcess(AbstractPollTask):
return self.pid is not None and \
self.returncode is None
+ def _async_wait(self):
+ if self.returncode is None:
+ raise asyncio.InvalidStateError('Result is not ready for %s' % (self,))
+ else:
+ # This calls _unregister, so don't call it until pid status
+ # is available.
+ super(SubProcess, self)._async_wait()
+
def _async_waitpid(self):
"""
Wait for exit status of self.pid asynchronously, and then