Home

faulthandler

Faulthandler is a Python standard library module that provides facilities for printing Python stack traces to help diagnose crashes, hangs, and deadlocks in Python programs. It is designed to offer quick visibility into what multiple threads are doing at the moment a fault occurs or on demand, without a full debugger.

The module can emit tracebacks for the current thread or for all threads, and it can include

On Unix-like systems, faulthandler can be configured to dump tracebacks in response to signals (for example,

Usage in brief involves importing the module and enabling it, then calling the available dump routines as

local
variables
when
requested.
Output
is
written
to
a
file-like
object,
with
the
default
being
standard
error.
Faulthandler
can
be
enabled
to
install
fault-dumping
behavior
that
activates
automatically
on
fatal
errors,
or
it
can
be
used
explicitly
to
dump
tracebacks
at
a
chosen
moment.
by
receiving
a
specific
signal
such
as
SIGUSR1),
enabling
operators
to
inspect
a
running
process
without
restarting
it.
The
functionality
is
designed
to
be
lightweight
and
non-intrusive,
making
it
suitable
for
production
use
in
long-running
services
and
background
workers.
needed.
It
is
capable
of
showing
the
Python-level
call
stacks
of
threads,
though
it
does
not
reveal
internal
details
inside
C
extensions
beyond
what
the
Python
interpreter
exposes.
While
not
a
replacement
for
a
full
debugger,
faulthandler
is
a
widely
used
diagnostic
aid
that
helps
developers
gather
actionable
information
during
faults
and
performance
issues
in
multi-threaded
Python
applications.