Skip to content

Commit

Permalink
Revert "bpo-33608: Factor out a private, per-interpreter _Py_AddPendi…
Browse files Browse the repository at this point in the history
…ngCall(). (pythongh-13714)" (pythonGH-13780)

This reverts commit 6a150bc.
  • Loading branch information
vstinner authored and DinoV committed Jan 14, 2020
1 parent db36cd1 commit a405d90
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 320 deletions.
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

0 comments on commit a405d90

Please sign in to comment.