Is there a way to catch exceptions that happen during interpreter shutdown?
I have a gui application, and sometimes I get a thread error during interpreter shutdown, but I can only see this exception when I start the program from cmd.exe in the shell. I would like to log this exception into one of my log files, but I can't find a way to first catch it.
asked Nov 11, 2013 at 11:12
Alexander Pope
1,2241 gold badge16 silver badges24 bronze badges
-
Could you provide further context? You get an exception when you run something from the shell, but.... when running in a GUI you still get it? What logging/handling is the GUI doing itself that's different from you launching whatever it is you're doing directly etc...?Jon Clements– Jon Clements2013年11月11日 11:21:45 +00:00Commented Nov 11, 2013 at 11:21
-
Sorry I wasn't clear enough. I suspect I still get that exception, but there is no indication of it when running from gui. I can only read the exception message when starting from shell(cmd.exe). I'm using wxpython for my GUI framework. The error message reads like this: <code>Exception in thread Thread-35 (most likely raised during interpreter shutdown):</code>Alexander Pope– Alexander Pope2013年11月11日 12:44:45 +00:00Commented Nov 11, 2013 at 12:44
1 Answer 1
One thing you can try is to overwrite sys.excepthook() with your own function to write the exception somewhere else than to stderr.
answered Nov 11, 2013 at 11:23
Sven Marnach
608k123 gold badges969 silver badges866 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py