SIGN IN SIGN UP

gh-149085: Add `max_threads` keyword to `faulthandler.dump_traceback()` (GH-149106)

Add a keyword-only `max_threads` argument to `dump_traceback()` and
`dump_traceback_later()`, defaulting to 100 to preserve existing
behavior. Allows server processes with many worker threads to dump
beyond the historical 100-thread cap (previously a hardcoded
`MAX_NTHREADS = 100` in `Python/traceback.c`).

The cap matters in practice: tstates are prepended to the
PyInterpreterState linked list, so the dump walks newest-first. With
more than 100 threads alive, the main thread (oldest, at the tail) is
silently elided from watchdog dumps -- exactly the thread that's
usually wanted.

The hardcoded value is moved to a new internal macro
`_Py_TRACEBACK_MAX_NTHREADS` in `pycore_traceback.h` so the in-tree
fatal-signal callers all reference one source of truth.
E
Eric Froemling committed
7686abe063eb7fbf85f33437b9256e0d9e0f4a4f
Parent: 4599335
Committed by GitHub <noreply@github.com> on 4/30/2026, 1:27:57 PM