python - Raise unhandled exceptions in a thread in the main thread? -
There are some similar questions, but no one needs to answer me.
If I make the thread through the threading Threads
, which then throw exceptions that are unchecked, those threads are terminated. I want to keep the default print of exception details with stack trace, but also brought down the entire process.
I believe that it is possible to catch all the exceptions in the thread, and it can be repeated on the main thread object, or it is possible to execute the default exception handling manually, and then a
What is the best way to go about this?
I wrote, in this way there is a lot to be included in this way.
You do this on your worker thread:
Try: self Except exceptions = self.do_something_dangerous (), e: import sys self.exc_info = sys.exc_info ()
and you do this on your main thread:
< Pre> if self.exc_info: increase self.exc_info [1], none, self.exc_info [2] back self. Result
The exception will be seen in the main form as if this worker was raised in the thread.
Comments
Post a Comment