Kyle Stanley <aeros...@gmail.com> added the comment:
> Regarding "is_running()", notice that it relies almost entirely on > "frame->f_executing". That might not be enough (or maybe the behavior there > changed). That would be worth checking out. Based on the above hint, I was able to make some progress on a potential solution. Thanks Eric. 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. 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. The above fix seems to completely remove the test failure that occurs in "interpreters.destroy(interp)" in "test_already_running" after running it several times, but I'm able to consistently reproduce the following: Exception in thread Thread-8: Traceback (most recent call last): File "/home/aeros/repos/aeros-cpython/Lib/threading.py", line 932, in _bootstrap_inner self.run() File "/home/aeros/repos/aeros-cpython/Lib/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/home/aeros/repos/aeros-cpython/Lib/test/test__xxsubinterpreters.py", line 51, in run interpreters.run_string(interp, dedent(f""" RuntimeError: unrecognized interpreter ID 46 test test__xxsubinterpreters failed -- Traceback (most recent call last): File "/home/aeros/repos/aeros-cpython/Lib/test/test__xxsubinterpreters.py", line 492, in test_subinterpreter self.assertTrue(interpreters.is_running(interp)) AssertionError: False is not true I have a few ideas that I'd like to test out for fixing this failure, and if any of them produce positive results I'll report back. Since the failures are still consistently occurring, I have not yer revised GH-16293. I'll do that when/if I come up with a more thorough solution. ---------- _______________________________________ 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