mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
faulthandler now works in non-Python threads
Issue #26563: * Add _PyGILState_GetInterpreterStateUnsafe() function: the single PyInterpreterState used by this process' GILState implementation. * Enhance _Py_DumpTracebackThreads() to retrieve the interpreter state from autoInterpreterState in last resort. The function now accepts NULL for interp and current_tstate parameters. * test_faulthandler: fix a ResourceWarning when test is interrupted by CTRL+c
This commit is contained in:
parent
c36674a2c5
commit
861d9abfcf
7 changed files with 164 additions and 48 deletions
|
@ -243,15 +243,23 @@ PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
|
|||
*/
|
||||
PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
|
||||
|
||||
/* Helper/diagnostic function - return 1 if the current thread
|
||||
* currently holds the GIL, 0 otherwise
|
||||
*/
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Issue #26558: Flag to disable PyGILState_Check().
|
||||
If set, PyGILState_Check() always return 1. */
|
||||
If set to non-zero, PyGILState_Check() always return 1. */
|
||||
PyAPI_DATA(int) _PyGILState_check_enabled;
|
||||
|
||||
/* Helper/diagnostic function - return 1 if the current thread
|
||||
currently holds the GIL, 0 otherwise.
|
||||
|
||||
The function returns 1 if _PyGILState_check_enabled is non-zero. */
|
||||
PyAPI_FUNC(int) PyGILState_Check(void);
|
||||
|
||||
/* Unsafe function to get the single PyInterpreterState used by this process'
|
||||
GILState implementation.
|
||||
|
||||
Return NULL before _PyGILState_Init() is called and after _PyGILState_Fini()
|
||||
is called. */
|
||||
PyAPI_FUNC(PyInterpreterState *) _PyGILState_GetInterpreterStateUnsafe(void);
|
||||
#endif
|
||||
|
||||
#endif /* #ifdef WITH_THREAD */
|
||||
|
|
|
@ -53,19 +53,32 @@ PyAPI_DATA(void) _Py_DumpTraceback(
|
|||
PyThreadState *tstate);
|
||||
|
||||
/* Write the traceback of all threads into the file 'fd'. current_thread can be
|
||||
NULL. Return NULL on success, or an error message on error.
|
||||
NULL.
|
||||
|
||||
Return NULL on success, or an error message on error.
|
||||
|
||||
This function is written for debug purpose only. It calls
|
||||
_Py_DumpTraceback() for each thread, and so has the same limitations. It
|
||||
only write the traceback of the first 100 threads: write "..." if there are
|
||||
more threads.
|
||||
|
||||
If current_tstate is NULL, the function tries to get the Python thread state
|
||||
of the current thread. It is not an error if the function is unable to get
|
||||
the current Python thread state.
|
||||
|
||||
If interp is NULL, the function tries to get the interpreter state from
|
||||
the current Python thread state, or from
|
||||
_PyGILState_GetInterpreterStateUnsafe() in last resort.
|
||||
|
||||
It is better to pass NULL to interp and current_tstate, the function tries
|
||||
different options to retrieve these informations.
|
||||
|
||||
This function is signal safe. */
|
||||
|
||||
PyAPI_DATA(const char*) _Py_DumpTracebackThreads(
|
||||
int fd, PyInterpreterState *interp,
|
||||
PyThreadState *current_thread);
|
||||
|
||||
int fd,
|
||||
PyInterpreterState *interp,
|
||||
PyThreadState *current_tstate);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue