crashmat provides a replacement for threading.Thread that, instead of printing unhandled exceptions in threads and then quietly killing it, will panic when a thread fails: it writes an error message to the log, attempts to call a graceful shutdown function, but ultimatly ensures that the process terminates (via signal.alarm()).
panic() attempts to terminate the python process completely.
If a shutdown_function has been set via set_shutdown_function() then this function will call signal.alarm(), and then it will call the shutdown function. This has the effect that if the shutdown function fails to kill the programe cracefully, it will die anyway in 60 seconds.
Otherwise, this function will simply raise SIGKILL, causing immediate death.
A Thread class that kills the process in response to unhandled exceptions.
This class behaves identically to threading.Thread, with the exception that if there is an unhandled exception, panic() will be called.
handle_exception() is called in response to an unhandled exception
It will call logging.Logger.exception() and then panic()