Revert "bpo-33608: Factor out a private, per-interpreter _Py_AddPendi… · python/cpython@e225beb (original) (raw)

10 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -12,22 +12,19 @@ extern "C" {
12 12 #include "pycore_pystate.h"
13 13 #include "pythread.h"
14 14
15 +PyAPI_FUNC(void) _Py_FinishPendingCalls(_PyRuntimeState *runtime);
15 16 PyAPI_FUNC(void) _PyEval_Initialize(struct _ceval_runtime_state *);
16 17 PyAPI_FUNC(void) _PyEval_FiniThreads(
17 -struct _ceval_runtime_state *);
18 +struct _ceval_runtime_state *ceval);
18 19 PyAPI_FUNC(void) _PyEval_SignalReceived(
19 -struct _ceval_runtime_state *);
20 +struct _ceval_runtime_state *ceval);
20 21 PyAPI_FUNC(int) _PyEval_AddPendingCall(
21 22 PyThreadState *tstate,
22 -struct _ceval_runtime_state *,
23 -struct _ceval_interpreter_state *,
24 -unsigned long thread_id,
23 +struct _ceval_runtime_state *ceval,
25 24 int (*func)(void *),
26 25 void *arg);
27 -PyAPI_FUNC(void) _PyEval_FinishPendingCalls(PyInterpreterState *);
28 26 PyAPI_FUNC(void) _PyEval_SignalAsyncExc(
29 -struct _ceval_runtime_state *,
30 -struct _ceval_interpreter_state *);
27 +struct _ceval_runtime_state *ceval);
31 28 PyAPI_FUNC(void) _PyEval_ReInitThreads(
32 29 _PyRuntimeState *runtime);
33 30
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ struct pyruntimestate;
25 25
26 26 /* ceval state */
27 27
28 -struct _ceval_pending_calls {
28 +struct _pending_calls {
29 29 int finishing;
30 30 PyThread_type_lock lock;
31 31 /* Request for running pending calls. */
@@ -36,7 +36,6 @@ struct _ceval_pending_calls {
36 36 int async_exc;
37 37 #define NPENDINGCALLS 32
38 38 struct {
39 -unsigned long thread_id;
40 39 int (*func)(void *);
41 40 void *arg;
42 41 } calls[NPENDINGCALLS];
@@ -54,21 +53,15 @@ struct _ceval_runtime_state {
54 53 int tracing_possible;
55 54 /* This single variable consolidates all requests to break out of
56 55 the fast path in the eval loop. */
57 -// XXX This can move to _ceval_interpreter_state once all parts
58 -// from COMPUTE_EVAL_BREAKER have moved under PyInterpreterState.
59 56 _Py_atomic_int eval_breaker;
60 57 /* Request for dropping the GIL */
61 58 _Py_atomic_int gil_drop_request;
59 +struct _pending_calls pending;
62 60 /* Request for checking signals. */
63 61 _Py_atomic_int signals_pending;
64 62 struct _gil_runtime_state gil;
65 63 };
66 64
67 -struct _ceval_interpreter_state {
68 -struct _ceval_pending_calls pending;
69 -};
70 -
71 -
72 65 /* interpreter state */
73 66
74 67 typedef PyObject* (*_PyFrameEvalFunction)(struct _frame *, int);
@@ -143,7 +136,6 @@ struct _is {
143 136
144 137 uint64_t tstate_next_unique_id;
145 138
146 -struct _ceval_interpreter_state ceval;
147 139 struct _warnings_runtime_state warnings;
148 140
149 141 PyObject *audit_hooks;
Original file line number Diff line number Diff line change
@@ -431,7 +431,7 @@ def pendingcalls_wait(self, l, n, context = None):
431 431 def test_pendingcalls_threaded(self):
432 432
433 433 #do every callback on a separate thread
434 -n = 32 #total callbacks (see NPENDINGCALLS in pycore_ceval.h)
434 +n = 32 #total callbacks
435 435 threads = []
436 436 class foo(object):pass
437 437 context = foo()
Original file line number Diff line number Diff line change
@@ -2677,7 +2677,6 @@ pending_threadfunc(PyObject *self, PyObject *arg)
2677 2677 Py_INCREF(callable);
2678 2678
2679 2679 Py_BEGIN_ALLOW_THREADS
2680 -/* XXX Use the internal _Py_AddPendingCall(). */
2681 2680 r = Py_AddPendingCall(&_pending_callback, callable);
2682 2681 Py_END_ALLOW_THREADS
2683 2682
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@
21 21 #include <process.h>
22 22 #endif
23 23 #endif
24 -#include "internal/pycore_pystate.h"
25 24
26 25 #ifdef HAVE_SIGNAL_H
27 26 #include <signal.h>
@@ -260,7 +259,6 @@ trip_signal(int sig_num)
260 259 /* Notify ceval.c */
261 260 _PyRuntimeState *runtime = &_PyRuntime;
262 261 PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
263 -PyInterpreterState *interp = runtime->interpreters.main;
264 262 _PyEval_SignalReceived(&runtime->ceval);
265 263
266 264 /* And then write to the wakeup fd *after* setting all the globals and
@@ -301,10 +299,7 @@ trip_signal(int sig_num)
301 299 {
302 300 /* Py_AddPendingCall() isn't signal-safe, but we
303 301 still use it for this exceptional case. */
304 -_PyEval_AddPendingCall(tstate,
305 -&runtime->ceval,
306 -&interp->ceval,
307 -runtime->main_thread,
302 +_PyEval_AddPendingCall(tstate, &runtime->ceval,
308 303 report_wakeup_send_error,
309 304 (void *)(intptr_t) last_error);
310 305 }
@@ -323,10 +318,7 @@ trip_signal(int sig_num)
323 318 {
324 319 /* Py_AddPendingCall() isn't signal-safe, but we
325 320 still use it for this exceptional case. */
326 -_PyEval_AddPendingCall(tstate,
327 -&runtime->ceval,
328 -&interp->ceval,
329 -runtime->main_thread,
321 +_PyEval_AddPendingCall(tstate, &runtime->ceval,
330 322 report_wakeup_write_error,
331 323 (void *)(intptr_t)errno);
332 324 }