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
This commit is contained in:
Geoff Brown 2021-02-25 21:02:14 +00:00
Родитель 2c9b489fbe
Коммит c6f86c79ea
1 изменённых файлов: 12 добавлений и 3 удалений

Просмотреть файл

@ -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):