From 4be18fcf473b5bff57daa1b57e3de961134a546a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 6 Jun 2019 15:07:52 +0100 Subject: detect monkey exit rather than waiting forever for a defunct process --- test/monkeyfarmer.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/monkeyfarmer.py b/test/monkeyfarmer.py index cbd979cad..539fab597 100644 --- a/test/monkeyfarmer.py +++ b/test/monkeyfarmer.py @@ -55,7 +55,17 @@ class MonkeyFarmer(asyncore.dispatcher): def handle_connect(self): pass + + def handle_close(self): + # the pipe to the monkey process has closed + # ensure the child process is finished and report the exit + self.close() + if self.monkey.poll() is None: + self.monkey.terminate() + self.monkey.wait() + self.lines.insert(0, "GENERIC EXIT {}".format(self.monkey.returncode).encode('utf-8')) + def handle_read(self): got = self.recv(8192) if not got: @@ -162,6 +172,10 @@ class Browser: self.stopped = True elif what == 'LAUNCH': self.launchurl = args[1] + elif what == 'EXIT': + if not self.stopped: + print("Unexpected exit of monkey process with code {}".format(args[0])) + assert(self.stopped) else: # TODO: Nothing for now? pass -- cgit v1.2.3