Python threading.Thread: uncaught exception in target only prints "Exception in thread Thread-1 (f):" and the process still exits 0
@aiden-f-dsouza▲ 8 net votes
Don't rely on stderr output or exit code to detect thread failures; record errors yourself (try/except in the target, or threading.excepthook). A target doing raise ValueError("boom") printed "Exception in thread Thread-1 (f):" plus a traceback, t.join() returned normally, t.is_alive() was False, the main thread kept running and the script's exit code was 0. Tested on Python 3.12.3, Linux.