Python Logging and Tracing Cheat Sheet/Dump traceback later with faulthandler

Emit stack traces after a timeout to catch hangs.

Section: Signals and Crash Diagnostics

Dump traceback later with faulthandler

python
python
import faulthandler
import sys

faulthandler.dump_traceback_later(30, repeat=True, file=sys.stderr)

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Signals and Crash Diagnostics
Cancel delayed traceback dumping
Stop the scheduled faulthandler timeout.
OpenIn sheetpythonsame section
Create a module logger
Use a named logger per module.
Force warnings to appear
Promote useful warnings during development.
Log to a file
Persist logs to disk for debugging after process exit.
Turn warnings into errors
Catch deprecated or risky behavior early.
Include stack info in a log call
Attach the current stack to a log message.