From c6f86c79ea03f2200ccb105a7d08dce0886c4d48 Mon Sep 17 00:00:00 2001 From: Geoff Brown Date: Thu, 25 Feb 2021 21:02:14 +0000 Subject: [PATCH] Bug 1694275 - Handle exceptions in mozprocess callbacks; r=jmaher Catch and report any exceptions raised in mozprocess callbacks. This allows the ProcessReader thread to continue and mozprocess to function normally following an exception raised in client code. Differential Revision: https://phabricator.services.mozilla.com/D106536 --- .../mozprocess/mozprocess/processhandler.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/testing/mozbase/mozprocess/mozprocess/processhandler.py b/testing/mozbase/mozprocess/mozprocess/processhandler.py index 1877541f2bdf..688980df5be6 100644 --- a/testing/mozbase/mozprocess/mozprocess/processhandler.py +++ b/testing/mozbase/mozprocess/mozprocess/processhandler.py @@ -1277,15 +1277,24 @@ class ProcessReader(object): # process remaining lines to read while not queue.empty(): line, callback = queue.get(False) - callback(line.rstrip()) + try: + callback(line.rstrip()) + except Exception: + traceback.print_exc() if timed_out: - self.timeout_callback() + try: + self.timeout_callback() + except Exception: + traceback.print_exc() if stdout_reader: stdout_reader.join() if stderr_reader: stderr_reader.join() if not timed_out: - self.finished_callback() + try: + self.finished_callback() + except Exception: + traceback.print_exc() self.debug("_read exited") def is_alive(self):