Eric Snow <ericsnowcurren...@gmail.com> added the comment:
On Sat, Nov 30, 2019 at 9:23 PM Kyle Stanley <rep...@bugs.python.org> wrote: > Based on the above hint, I was able to make some progress on a potential > solution. Thanks Eric. That's great! > Instead of only checking "frame->f_executing", I changed "_is_running()" to > also check the > "finalizing" field of PyInterpreterState. The "finalizing" field is set to 1 > in "Py_EndInterpreter()", > so this ensures that an interpreter in the process of being destroyed is > considered "running", > so that operations (such as running scripts, destroying the interpreter, etc) > can't occur during > finalization. Ah, that makes sense. > I had to add a private function to the C-API in order to access > "interp->finalizing" from > Modules/_xxsubinterpretersmodule.c due to the struct for PyInterpreterState > being internal only. Yep, it has to use the public C-API just like any other module. The function has a "_Py" prefix and be defined in Include/cpython, right? ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37224> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com