Skip to content

Commit b13d1e5

Browse files
committed
Move stop-the-world call before setting finalized
1 parent c2ebedb commit b13d1e5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Python/pylifecycle.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,16 +1911,16 @@ Py_FinalizeEx(void)
19111911
int malloc_stats = tstate->interp->config.malloc_stats;
19121912
#endif
19131913

1914+
/* Ensure that remaining threads are detached */
1915+
_PyEval_StopTheWorldAll(runtime);
1916+
19141917
/* Remaining daemon threads will automatically exit
19151918
when they attempt to take the GIL (ex: PyEval_RestoreThread()). */
19161919
_PyInterpreterState_SetFinalizing(tstate->interp, tstate);
19171920
_PyRuntimeState_SetFinalizing(runtime, tstate);
19181921
runtime->initialized = 0;
19191922
runtime->core_initialized = 0;
19201923

1921-
/* Ensure that remaining threads are detached */
1922-
_PyEval_StopTheWorldAll(runtime);
1923-
19241924
// XXX Call something like _PyImport_Disable() here?
19251925

19261926
/* Destroy the state of all threads of the interpreter, except of the

0 commit comments

Comments
 (0)