From cbe6be449e7f51e0cae6207ffbf78e1a89de4c81 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sat, 21 Apr 2018 17:51:59 +0100 Subject: [PATCH] issue #201: parent: log a warning and work around race for now. --- mitogen/parent.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mitogen/parent.py b/mitogen/parent.py index 36ecb295..1173da09 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -26,6 +26,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +import errno import fcntl import getpass import inspect @@ -593,7 +594,15 @@ class Stream(mitogen.core.Stream): # on_disconnect() call. return - pid, status = os.waitpid(self.pid, os.WNOHANG) + try: + pid, status = os.waitpid(self.pid, os.WNOHANG) + except OSError: + e = sys.exc_info()[1] + if e.args[0] == errno.ECHILD: + LOG.warn('%r: waitpid(%r) produced ECHILD', self.pid, self) + return + raise + if pid: LOG.debug('%r: child process exit status was %d', self, status) else: