STINNER Victor <vstin...@python.org> added the comment:
In the master branch of Python, trip_signal() calls _PyEval_AddPendingCall(tstate) and tstate is get using _PyRuntimeState_GetThreadState(runtime). trip_signal() can be called while the GIL is not held: tstate is NULL in this case. For example, it's the case when calling signal.raise_signal(). Problem: _PyEval_AddPendingCall() uses tstate if pending->finishing is non-zero. if (pending->finishing) { ... _PyErr_Fetch(tstate, &exc, &val, &tb); _PyErr_SetString(tstate, PyExc_SystemError, "Py_AddPendingCall: cannot add pending calls " "(Python shutting down)"); ... } pending->finishing was addd in bpo-33608 by the change: commit 842a2f07f2f08a935ef470bfdaeef40f87490cfc Author: Eric Snow <ericsnowcurren...@gmail.com> Date: Fri Mar 15 15:47:51 2019 -0600 bpo-33608: Deal with pending calls relative to runtime shutdown. (gh-12246) I found this issue while trying to make pending calls per interpreter in bpo-39984: move pending from _PyRuntimeState to PyInterpreterState. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37127> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com