mirror of
https://github.com/python/cpython.git
synced 2026-01-04 14:32:21 +00:00
gh-104341: Adjust tstate_must_exit() to Respect Interpreter Finalization (gh-104437)
With the move to a per-interpreter GIL, this check slipped through the cracks.
This commit is contained in:
parent
cb88ae635e
commit
26baa747c2
11 changed files with 56 additions and 10 deletions
|
|
@ -1436,11 +1436,13 @@ PyThreadState_Clear(PyThreadState *tstate)
|
|||
|
||||
if (verbose && tstate->cframe->current_frame != NULL) {
|
||||
/* bpo-20526: After the main thread calls
|
||||
_PyRuntimeState_SetFinalizing() in Py_FinalizeEx(), threads must
|
||||
exit when trying to take the GIL. If a thread exit in the middle of
|
||||
_PyEval_EvalFrameDefault(), tstate->frame is not reset to its
|
||||
previous value. It is more likely with daemon threads, but it can
|
||||
happen with regular threads if threading._shutdown() fails
|
||||
_PyInterpreterState_SetFinalizing() in Py_FinalizeEx()
|
||||
(or in Py_EndInterpreter() for subinterpreters),
|
||||
threads must exit when trying to take the GIL.
|
||||
If a thread exit in the middle of _PyEval_EvalFrameDefault(),
|
||||
tstate->frame is not reset to its previous value.
|
||||
It is more likely with daemon threads, but it can happen
|
||||
with regular threads if threading._shutdown() fails
|
||||
(ex: interrupted by CTRL+C). */
|
||||
fprintf(stderr,
|
||||
"PyThreadState_Clear: warning: thread still has a frame\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue