Skip to content

Revert "bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). (gh-13714)" #13780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ extern "C" {
#include "pycore_pystate.h"
#include "pythread.h"

PyAPI_FUNC(void) _Py_FinishPendingCalls(_PyRuntimeState *runtime);
PyAPI_FUNC(void) _PyEval_Initialize(struct _ceval_runtime_state *);
PyAPI_FUNC(void) _PyEval_FiniThreads(
struct _ceval_runtime_state *);
struct _ceval_runtime_state *ceval);
PyAPI_FUNC(void) _PyEval_SignalReceived(
struct _ceval_runtime_state *);
struct _ceval_runtime_state *ceval);
PyAPI_FUNC(int) _PyEval_AddPendingCall(
PyThreadState *tstate,
struct _ceval_runtime_state *,
struct _ceval_interpreter_state *,
unsigned long thread_id,
struct _ceval_runtime_state *ceval,
int (*func)(void *),
void *arg);
PyAPI_FUNC(void) _PyEval_FinishPendingCalls(PyInterpreterState *);
PyAPI_FUNC(void) _PyEval_SignalAsyncExc(
struct _ceval_runtime_state *,
struct _ceval_interpreter_state *);
struct _ceval_runtime_state *ceval);
PyAPI_FUNC(void) _PyEval_ReInitThreads(
_PyRuntimeState *runtime);

Expand Down
12 changes: 2 additions & 10 deletions Include/internal/pycore_pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct pyruntimestate;

/* ceval state */

struct _ceval_pending_calls {
struct _pending_calls {
int finishing;
PyThread_type_lock lock;
/* Request for running pending calls. */
Expand All @@ -36,7 +36,6 @@ struct _ceval_pending_calls {
int async_exc;
#define NPENDINGCALLS 32
struct {
unsigned long thread_id;
int (*func)(void *);
void *arg;
} calls[NPENDINGCALLS];
Expand All @@ -54,21 +53,15 @@ struct _ceval_runtime_state {
int tracing_possible;
/* This single variable consolidates all requests to break out of
the fast path in the eval loop. */
// XXX This can move to _ceval_interpreter_state once all parts
// from COMPUTE_EVAL_BREAKER have moved under PyInterpreterState.
_Py_atomic_int eval_breaker;
/* Request for dropping the GIL */
_Py_atomic_int gil_drop_request;
struct _pending_calls pending;
/* Request for checking signals. */
_Py_atomic_int signals_pending;
struct _gil_runtime_state gil;
};

struct _ceval_interpreter_state {
struct _ceval_pending_calls pending;
};


/* interpreter state */

typedef PyObject* (*_PyFrameEvalFunction)(struct _frame *, int);
Expand Down Expand Up @@ -143,7 +136,6 @@ struct _is {

uint64_t tstate_next_unique_id;

struct _ceval_interpreter_state ceval;
struct _warnings_runtime_state warnings;

PyObject *audit_hooks;
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def pendingcalls_wait(self, l, n, context = None):
def test_pendingcalls_threaded(self):

#do every callback on a separate thread
n = 32 #total callbacks (see NPENDINGCALLS in pycore_ceval.h)
n = 32 #total callbacks
threads = []
class foo(object):pass
context = foo()
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2677,7 +2677,6 @@ pending_threadfunc(PyObject *self, PyObject *arg)
Py_INCREF(callable);

Py_BEGIN_ALLOW_THREADS
/* XXX Use the internal _Py_AddPendingCall(). */
r = Py_AddPendingCall(&_pending_callback, callable);
Py_END_ALLOW_THREADS

Expand Down
12 changes: 2 additions & 10 deletions Modules/signalmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <process.h>
#endif
#endif
#include "internal/pycore_pystate.h"

#ifdef HAVE_SIGNAL_H
#include <signal.h>
Expand Down Expand Up @@ -260,7 +259,6 @@ trip_signal(int sig_num)
/* Notify ceval.c */
_PyRuntimeState *runtime = &_PyRuntime;
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
PyInterpreterState *interp = runtime->interpreters.main;
_PyEval_SignalReceived(&runtime->ceval);

/* And then write to the wakeup fd *after* setting all the globals and
Expand Down Expand Up @@ -301,10 +299,7 @@ trip_signal(int sig_num)
{
/* Py_AddPendingCall() isn't signal-safe, but we
still use it for this exceptional case. */
_PyEval_AddPendingCall(tstate,
&runtime->ceval,
&interp->ceval,
runtime->main_thread,
_PyEval_AddPendingCall(tstate, &runtime->ceval,
report_wakeup_send_error,
(void *)(intptr_t) last_error);
}
Expand All @@ -323,10 +318,7 @@ trip_signal(int sig_num)
{
/* Py_AddPendingCall() isn't signal-safe, but we
still use it for this exceptional case. */
_PyEval_AddPendingCall(tstate,
&runtime->ceval,
&interp->ceval,
runtime->main_thread,
_PyEval_AddPendingCall(tstate, &runtime->ceval,
report_wakeup_write_error,
(void *)(intptr_t)errno);
}
Expand Down
Loading