Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-113433: Automatically Clean Up Subinterpreters in Py_Finalize() #121060

Merged
Prev Previous commit
Clean up subinterpreters only after modules (incl. __main__) have bee…
…n cleaned up.
  • Loading branch information
ericsnowcurrently committed Jun 26, 2024
commit 86cd3dd38d3d544773e23cd434fc808b547a04f2
4 changes: 3 additions & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1999,7 +1999,6 @@ _Py_Finalize(_PyRuntimeState *runtime)
_PyAtExit_Call(tstate->interp);

assert(_PyThreadState_GET() == tstate);
finalize_subinterpreters();

/* Copy the core config, PyInterpreterState_Delete() free
the core config memory */
Expand Down Expand Up @@ -2081,6 +2080,9 @@ _Py_Finalize(_PyRuntimeState *runtime)
_PyImport_FiniExternal(tstate->interp);
finalize_modules(tstate);

/* Clean up any lingering subinterpreters. */
finalize_subinterpreters();

/* Print debug stats if any */
_PyEval_Fini();

Expand Down
Loading