Skip to content

Commit 86cd3dd

Browse files
Clean up subinterpreters only after modules (incl. __main__) have been cleaned up.
1 parent 02a969a commit 86cd3dd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Python/pylifecycle.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1999,7 +1999,6 @@ _Py_Finalize(_PyRuntimeState *runtime)
19991999
_PyAtExit_Call(tstate->interp);
20002000

20012001
assert(_PyThreadState_GET() == tstate);
2002-
finalize_subinterpreters();
20032002

20042003
/* Copy the core config, PyInterpreterState_Delete() free
20052004
the core config memory */
@@ -2081,6 +2080,9 @@ _Py_Finalize(_PyRuntimeState *runtime)
20812080
_PyImport_FiniExternal(tstate->interp);
20822081
finalize_modules(tstate);
20832082

2083+
/* Clean up any lingering subinterpreters. */
2084+
finalize_subinterpreters();
2085+
20842086
/* Print debug stats if any */
20852087
_PyEval_Fini();
20862088

0 commit comments

Comments
 (0)