Skip to content

Commit d61099e

Browse files
committed
Move call to finalize_subinterpreters()
1 parent 1555731 commit d61099e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Python/pylifecycle.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,16 @@ _Py_Finalize(_PyRuntimeState *runtime)
20282028

20292029
_PyAtExit_Call(tstate->interp);
20302030

2031+
/* Clean up any lingering subinterpreters.
2032+
2033+
Two preconditions need to be met here:
2034+
2035+
- This has to happen before _PyRuntimeState_SetFinalizing is
2036+
called, or else threads might get prematurely blocked.
2037+
- The world must not be stopped, as finalizers can run.
2038+
*/
2039+
finalize_subinterpreters();
2040+
20312041
assert(_PyThreadState_GET() == tstate);
20322042

20332043
/* Copy the core config, PyInterpreterState_Delete() free
@@ -2043,16 +2053,6 @@ _Py_Finalize(_PyRuntimeState *runtime)
20432053
int malloc_stats = tstate->interp->config.malloc_stats;
20442054
#endif
20452055

2046-
/* Clean up any lingering subinterpreters.
2047-
2048-
Two preconditions need to be met here:
2049-
2050-
- This has to happen before _PyRuntimeState_SetFinalizing is
2051-
called, or else threads might get prematurely blocked.
2052-
- The world must not be stopped, as finalizers can run.
2053-
*/
2054-
finalize_subinterpreters();
2055-
20562056
/* Ensure that remaining threads are detached */
20572057
_PyEval_StopTheWorldAll(runtime);
20582058

0 commit comments

Comments
 (0)