I published that here:
https://pypi.org/project/better_exchook/ https://github.com/albertz/py_better_exchook
I also often have a SIGUSR1 handler which will print the stacktrace of all threads. This is useful on long running processes, involving multi threading, where you might run into some strange hangs or deadlocks.
In addition to that, if you might get crashes (segfault or so), something like faulthandler is useful.
If you also want to see the C stack trace in addition in such cases, I load libSegFault.so, like here: https://github.com/rwth-i6/returnn/blob/5b8e34ec1fd725d0e20b...
Profiling is another topic. Something like Py-Spy (https://github.com/benfred/py-spy) can be very helpful.
I also found a remote background ZMQ IPython/Jupyter kernel to be useful sometimes. I published that here: https://github.com/albertz/background-zmq-ipython