From cba9d1e2249464ab169ee7d6a164ebee883397fa Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sat, 4 Feb 2023 21:52:24 -0700 Subject: [PATCH] main.py: Add traceback logging in spawned threads --- resources/main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/resources/main.py b/resources/main.py index c868eea5f..0ff3464b6 100644 --- a/resources/main.py +++ b/resources/main.py @@ -6,7 +6,7 @@ from pathlib import Path import time import threading import logging -import traceback +import threading from resources import cli_menu, constants, utilities, device_probe, os_probe, defaults, arguments, install, tui_helpers, reroute_payloads, commit_info from resources.build import build @@ -53,11 +53,15 @@ class OpenCoreLegacyPatcher: def implement_custom_traceback_handler(self): - # TODO: Support thread exceptions + # Reroute traceback to logging def custom_excepthook(type, value, tb): - logging.error("Uncaught exception", exc_info=(type, value, tb)) + logging.error("Uncaught exception in main thread", exc_info=(type, value, tb)) + + def custom_thread_excepthook(args): + logging.error("Uncaught exception in spawned thread", exc_info=(args)) sys.excepthook = custom_excepthook + threading.excepthook = custom_thread_excepthook def generate_base_data(self):