GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-149085: Add max_threads keyword to faulthandler.dump_traceback() by efroemling · Pull Request #149106 · python/cpython Conversation
|
Documentation build overview
6 files changed ·
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to also add max_threads parameter to enable().
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
- Drop _Py_TRACEBACK_MAX_NTHREADS macro; use 0 as sentinel for default 100 inside _Py_DumpTracebackThreads so internal callers don't have to pass the default explicitly. - Rename max_nthreads -> max_threads everywhere for naming consistency with the public Python kwarg. - Add max_threads kwarg to faulthandler.enable(); store in fatal_error.max_threads and pass through faulthandler_dump_traceback to the fatal-signal dump path on both POSIX and Windows. - Drop the three redundant explanatory comments vstinner flagged. - Doc: tighten the limitations bullet, drop implementation-detail mentions of the "..." truncation marker, switch versionchanged directives to "next", document the new enable() kwarg. - Tests: assertEqual exact count, check whole-line "\n...\n" marker, use script_helper.assert_python_ok, drop the default-value test, add test_enable_max_threads exercising the fatal-signal path. - NEWS: trim to two lines, mention all three functions.
There was an error while loading. Please reload this page.
|
Thanks for the feedback. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The fatal-signal handler only dumps the current thread when the GIL is disabled (pythongh-104812 / 3.14 versionchanged), so the truncation marker assertion in test_enable_max_threads fails on free-threading CI runs. Skip it there.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you replace unsigned int max_threads with Py_ssize_t max_threads? Replace also unsigned int nthreads with Py_ssize_t nthreads in _Py_DumpTracebackThreads().
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return; | ||
|
|
||
| faulthandler_dump_traceback(user->fd, user->all_threads, user->interp); | ||
| faulthandler_dump_traceback(user->fd, user->all_threads, user->interp, 0); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please modify faulthandler.register() to add a max_threads parameter.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Thanks for this big update! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please also add an entry to "What's New in Python 3.15".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
- Add a 'faulthandler' entry to Doc/whatsnew/3.15.rst (per @ZeroIntensity). - Switch the max_threads parameters/fields and the nthreads loop counter in _Py_DumpTracebackThreads to Py_ssize_t (per @vstinner).
|
Ok I added the whats-new entry and switched the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Can you also modify |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Per @vstinner's follow-up: also wire the kwarg through register() / faulthandler_user. Stored in the per-signal user_signal_t struct; the user-signal handler now passes user->max_threads to faulthandler_dump_traceback instead of 0. Doc, whatsnew, and NEWS entries updated to list all four functions.
Mirrors test_enable_max_threads but uses register(SIGUSR1, ...) + os.kill round-trip, matching the existing test_register_* pattern.
|
Ok |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ready.wait() | ||
| faulthandler.register(signal.SIGUSR1, all_threads=True, | ||
| max_threads=CAP) | ||
| os.kill(os.getpid(), signal.SIGUSR1) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
To raise the signal, you can use:
| os.kill(os.getpid(), signal.SIGUSR1) | |
| signal.raise_signal(signal.SIGUSR1) |
Can you use test_dump_traceback_max_threads() code to cleanup threads?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
- Use signal.raise_signal() instead of os.kill(os.getpid(), ...). - Match test_dump_traceback_max_threads thread-cleanup pattern: keep refs, no daemon=True, set the stop event in a finally block, and join() the workers.
|
Ok; switched to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@ZeroIntensity: Do you want to double check the change? It would be good to merge this change before next Tuesday to have it in Python 3.15 beta1. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM as well.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks for contributing :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
faulthandler: make per-call thread dump cap configurable
There was an error while loading. Please reload this page.