diff options
Diffstat (limited to 'Python/pystate.c')
-rw-r--r-- | Python/pystate.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 44acfed..6731575 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -2,6 +2,7 @@ /* Thread and interpreter state structures and their interfaces */ #include "Python.h" +#include "pycore_ceval.h" #include "pycore_coreconfig.h" #include "pycore_pymem.h" #include "pycore_pystate.h" @@ -39,7 +40,6 @@ extern "C" { /* Forward declarations */ static PyThreadState *_PyGILState_GetThisThreadState(struct _gilstate_runtime_state *gilstate); static void _PyThreadState_Delete(_PyRuntimeState *runtime, PyThreadState *tstate); -static PyThreadState *_PyThreadState_Swap(struct _gilstate_runtime_state *gilstate, PyThreadState *newts); static _PyInitError @@ -867,9 +867,8 @@ PyThreadState_DeleteCurrent() * be kept in those other interpreteres. */ void -_PyThreadState_DeleteExcept(PyThreadState *tstate) +_PyThreadState_DeleteExcept(_PyRuntimeState *runtime, PyThreadState *tstate) { - _PyRuntimeState *runtime = &_PyRuntime; PyInterpreterState *interp = tstate->interp; PyThreadState *p, *next, *garbage; HEAD_LOCK(runtime); @@ -915,7 +914,7 @@ PyThreadState_Get(void) } -static PyThreadState * +PyThreadState * _PyThreadState_Swap(struct _gilstate_runtime_state *gilstate, PyThreadState *newts) { PyThreadState *oldts = _PyRuntimeGILState_GetThreadState(gilstate); @@ -980,8 +979,8 @@ PyThreadState_GetDict(void) int PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc) { - PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE(); - PyThreadState *p; + _PyRuntimeState *runtime = &_PyRuntime; + PyInterpreterState *interp = _PyRuntimeState_GetThreadState(runtime)->interp; /* Although the GIL is held, a few C API functions can be called * without the GIL held, and in particular some that create and @@ -989,9 +988,8 @@ PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc) * list of thread states we're traversing, so to prevent that we lock * head_mutex for the duration. */ - _PyRuntimeState *runtime = &_PyRuntime; HEAD_LOCK(runtime); - for (p = interp->tstate_head; p != NULL; p = p->next) { + for (PyThreadState *p = interp->tstate_head; p != NULL; p = p->next) { if (p->thread_id == id) { /* Tricky: we need to decref the current value * (if any) in p->async_exc, but that can in turn @@ -1005,7 +1003,7 @@ PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc) p->async_exc = exc; HEAD_UNLOCK(runtime); Py_XDECREF(old_exc); - _PyEval_SignalAsyncExc(); + _PyEval_SignalAsyncExc(&runtime->ceval); return 1; } } |