Register a handler for the signal 'signum'. Dump the traceback of the current thread, or of all threads if all_threads is True, into file. max_threads caps the number of threads dumped.
faulthandler/register
register