bpo-39984: Move pending calls to PyInterpreterState (GH-19066)
If Py_AddPendingCall() is called in a subinterpreter, the function is
now scheduled to be called from the subinterpreter, rather than being
called from the main interpreter.
Each subinterpreter now has its own list of scheduled calls.
* Move pending and eval_breaker fields from _PyRuntimeState.ceval
to PyInterpreterState.ceval.
* new_interpreter() now calls _PyEval_InitThreads() to create
pending calls lock.
* Fix Py_AddPendingCall() for subinterpreters. It now calls
_PyThreadState_GET() which works in a subinterpreter if the
caller holds the GIL, and only falls back on
PyGILState_GetThisThreadState() if _PyThreadState_GET()
returns NULL.
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 1028531..a26ae7d 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -304,7 +304,7 @@
if (wakeup.warn_on_full_buffer ||
last_error != WSAEWOULDBLOCK)
{
- /* Py_AddPendingCall() isn't signal-safe, but we
+ /* _PyEval_AddPendingCall() isn't signal-safe, but we
still use it for this exceptional case. */
_PyEval_AddPendingCall(tstate,
report_wakeup_send_error,
@@ -323,7 +323,7 @@
if (wakeup.warn_on_full_buffer ||
(errno != EWOULDBLOCK && errno != EAGAIN))
{
- /* Py_AddPendingCall() isn't signal-safe, but we
+ /* _PyEval_AddPendingCall() isn't signal-safe, but we
still use it for this exceptional case. */
_PyEval_AddPendingCall(tstate,
report_wakeup_write_error,