[issue24554] GC should happen when a subinterpreter is destroyed
STINNER Victor
report at bugs.python.org
Mon Dec 9 05:14:07 EST 2019
STINNER Victor <vstinner at python.org> added the comment:
This issue is partially fixed in the master branch. Extract of the finalize_interp_clear() function, called by Py_EndInterpreter():
/* Clear interpreter state and all thread states */
PyInterpreterState_Clear(tstate->interp);
/* Trigger a GC collection on subinterpreters*/
if (!is_main_interp) {
_PyGC_CollectNoFail();
}
gc.collect() is now called.
It's only "partially" fixed because I would prefer to trigger a GC collection before or during PyInterpreterState_Clear(). IMHO trigger it after PyInterpreterState_Clear() creates a risk of crash in finalizers written in C which don't handle well before called very late during Python finalization. After PyInterpreterState_Clear(), Python is basically unusable. All modules are cleared.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue24554>
_______________________________________
More information about the Python-bugs-list
mailing list