-
Notifications
You must be signed in to change notification settings - Fork 26
Home
Fault handler for SIGSEGV, SIGFPE, SIGBUS and SIGILL signals: display the Python backtrace and restore the previous handler. Allocate an alternate stack for this handler, if sigaltstack() is available, to be able to allocate memory on the stack, even on stack overflow (not available on Windows).
Import the module and call faulthandler.enable() to enable the fault handler.
The fault handler is called on catastrophic cases and so it can only use signal-safe functions (eg. it doesn't allocate memory on the heap). That's why the backtrace is limited: it only supports ASCII encoding (use the backslashreplace error handler for non-ASCII characters), doesn't print the source code in the backtrace (only the filename, the function name and the line number), is limited to 100 frames and 100 threads.
By default, the Python backtrace is written to the standard error stream. Start your graphical applications in a terminal and run your server in foreground to see the backtrace, or pass a file to faulthandler.enable().
faulthandler is implemented in C using signal handlers to be able to dump a backtrace on a crash or when Python is blocked (eg. deadlock).
See the README file for more information.
- Source code: faulthandler-1.5.tar.gz
- Windows installer:
- Python 2.6: faulthandler-1.5.win32-py2.6.exe
- Python 2.7: faulthandler-1.5.win32-py2.7.exe
- Python 3.1: faulthandler-1.5.win32-py3.1.exe
- Python 3.2: faulthandler-1.5.win32-py3.2.exe
- See also faulthandler on the Python Package Index.