Skip to content

Commit b75b1a3

Browse files
bpo-33608: Revert "Factor out a private, per-interpreter _Py_AddPendingCall()." (gh-12806)
This reverts commit f13c5c8 (gh-12360).
1 parent f938d8b commit b75b1a3

File tree

11 files changed

+108
-151
lines changed

11 files changed

+108
-151
lines changed

Include/ceval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ PyAPI_FUNC(Py_ssize_t) _PyEval_RequestCodeExtraIndex(freefunc);
221221
#ifndef Py_LIMITED_API
222222
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
223223
PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
224-
PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyInterpreterState *);
224+
PyAPI_FUNC(void) _PyEval_SignalAsyncExc(void);
225225
#endif
226226

227227
/* Masks and values used by FORMAT_VALUE opcode. */

Include/internal/pycore_ceval.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ extern "C" {
1111
#include "pycore_atomic.h"
1212
#include "pythread.h"
1313

14-
struct _is; // See PyInterpreterState in cpython/pystate.h.
15-
16-
PyAPI_FUNC(int) _Py_AddPendingCall(struct _is*, unsigned long, int (*)(void *), void *);
17-
PyAPI_FUNC(int) _Py_MakePendingCalls(struct _is*);
18-
PyAPI_FUNC(void) _Py_FinishPendingCalls(struct _is*);
14+
PyAPI_FUNC(void) _Py_FinishPendingCalls(void);
1915

2016
struct _pending_calls {
2117
int finishing;
@@ -28,21 +24,13 @@ struct _pending_calls {
2824
int async_exc;
2925
#define NPENDINGCALLS 32
3026
struct {
31-
unsigned long thread_id;
3227
int (*func)(void *);
3328
void *arg;
3429
} calls[NPENDINGCALLS];
3530
int first;
3631
int last;
3732
};
3833

39-
struct _ceval_interpreter_state {
40-
/* This single variable consolidates all requests to break out of
41-
the fast path in the eval loop. */
42-
_Py_atomic_int eval_breaker;
43-
struct _pending_calls pending;
44-
};
45-
4634
#include "pycore_gil.h"
4735

4836
struct _ceval_runtime_state {
@@ -53,8 +41,12 @@ struct _ceval_runtime_state {
5341
c_tracefunc. This speeds up the if statement in
5442
PyEval_EvalFrameEx() after fast_next_opcode. */
5543
int tracing_possible;
44+
/* This single variable consolidates all requests to break out of
45+
the fast path in the eval loop. */
46+
_Py_atomic_int eval_breaker;
5647
/* Request for dropping the GIL */
5748
_Py_atomic_int gil_drop_request;
49+
struct _pending_calls pending;
5850
/* Request for checking signals. */
5951
_Py_atomic_int signals_pending;
6052
struct _gil_runtime_state gil;

Include/internal/pycore_pystate.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ extern "C" {
1212
#include "pystate.h"
1313
#include "pythread.h"
1414

15-
#include "pycore_atomic.h"
1615
#include "pycore_ceval.h"
1716
#include "pycore_pathconfig.h"
1817
#include "pycore_pymem.h"
@@ -84,8 +83,6 @@ struct _is {
8483
PyObject *pyexitmodule;
8584

8685
uint64_t tstate_next_unique_id;
87-
88-
struct _ceval_interpreter_state ceval;
8986
};
9087

9188
PyAPI_FUNC(struct _is*) _PyInterpreterState_LookUpID(PY_INT64_T);

Lib/test/test_capi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def pendingcalls_wait(self, l, n, context = None):
373373
def test_pendingcalls_threaded(self):
374374

375375
#do every callback on a separate thread
376-
n = 32 #total callbacks (see NPENDINGCALLS in pycore_ceval.h)
376+
n = 32 #total callbacks
377377
threads = []
378378
class foo(object):pass
379379
context = foo()

Misc/NEWS.d/next/Core and Builtins/2018-09-15-12-13-46.bpo-33608.avmvVP.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

Modules/_testcapimodule.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2445,7 +2445,6 @@ pending_threadfunc(PyObject *self, PyObject *arg)
24452445
Py_INCREF(callable);
24462446

24472447
Py_BEGIN_ALLOW_THREADS
2448-
/* XXX Use the internal _Py_AddPendingCall(). */
24492448
r = Py_AddPendingCall(&_pending_callback, callable);
24502449
Py_END_ALLOW_THREADS
24512450

Modules/signalmodule.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <process.h>
2020
#endif
2121
#endif
22-
#include "internal/pycore_pystate.h"
2322

2423
#ifdef HAVE_SIGNAL_H
2524
#include <signal.h>
@@ -296,10 +295,8 @@ trip_signal(int sig_num)
296295
{
297296
/* Py_AddPendingCall() isn't signal-safe, but we
298297
still use it for this exceptional case. */
299-
_Py_AddPendingCall(_PyRuntime.interpreters.main,
300-
main_thread,
301-
report_wakeup_send_error,
302-
(void *)(intptr_t) last_error);
298+
Py_AddPendingCall(report_wakeup_send_error,
299+
(void *)(intptr_t) last_error);
303300
}
304301
}
305302
}
@@ -316,10 +313,8 @@ trip_signal(int sig_num)
316313
{
317314
/* Py_AddPendingCall() isn't signal-safe, but we
318315
still use it for this exceptional case. */
319-
_Py_AddPendingCall(_PyRuntime.interpreters.main,
320-
main_thread,
321-
report_wakeup_write_error,
322-
(void *)(intptr_t)errno);
316+
Py_AddPendingCall(report_wakeup_write_error,
317+
(void *)(intptr_t)errno);
323318
}
324319
}
325320
}

0 commit comments

Comments
 (0)