这个问题在这里已有答案:
是否有可能在Python
中捕获uncaught exceptions
中引发的QThread
,以便父线程捕获子线程中的异常。在Java中,我会使用UncaughtExceptionHandler。
每当异常被提出并且未被捕获时,就会调用sys.excepthook
;也许你可以通过一种方式来看到未捕获的异常就是尝试这个:
def raise_exception(*args):
# print info when raising uncaught exception
print(args)
sys.excepthook = raise_exception