]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-149085: Add `max_threads` keyword to `faulthandler.dump_traceback()` (GH-149106)
authorEric Froemling <ericfroemling@gmail.com>
Thu, 30 Apr 2026 13:27:57 +0000 (06:27 -0700)
committerGitHub <noreply@github.com>
Thu, 30 Apr 2026 13:27:57 +0000 (09:27 -0400)
commit7686abe063eb7fbf85f33437b9256e0d9e0f4a4f
tree7d0e062cff92ce542cd8c67047e446bf1d12331b
parent4599335a83a22cf73a0c20e3692c29fd0278d23b
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.
14 files changed:
Doc/library/faulthandler.rst
Doc/whatsnew/3.15.rst
Include/internal/pycore_faulthandler.h
Include/internal/pycore_global_objects_fini_generated.h
Include/internal/pycore_global_strings.h
Include/internal/pycore_runtime_init_generated.h
Include/internal/pycore_traceback.h
Include/internal/pycore_unicodeobject_generated.h
Lib/test/test_faulthandler.py
Misc/NEWS.d/next/Library/2026-04-28-16-30-48.gh-issue-149085.5aNgBD.rst [new file with mode: 0644]
Modules/clinic/faulthandler.c.h
Modules/faulthandler.c
Python/pylifecycle.c
Python/traceback.c