파이썬
pyqt5 에서 exception 발생시 종료 방지 방법
헬로르르
2018. 8. 3. 21:10
def my_exception_hook(exctype, value, traceback):
# Print the error and traceback
print(exctype, value, traceback)
# Call the normal Exception hook after
sys._excepthook(exctype, value, traceback)
# sys.exit(1)
# Back up the reference to the exceptionhook
sys._excepthook = sys.excepthook
# Set the exception hook to our wrapping function
sys.excepthook = my_exception_hook
위 처럼 pyqt5 앱을 실행 시키기 전에, exception hook 을 새로 define에서 바꿔주시면 됩니다.
그러면 pyqt5 동작 중에도 강제로 프로그램이 종료되지 않을 거에요. 특히 .pyw 로 콘솔창 없이 하시는 분들은 위에기능은 필수적으로
필요하실 듯 합니다.