Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d2be5b4

Browse files
committed
remove gil_drop_request in --without-threads
1 parent b4ba986 commit d2be5b4

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

Python/ceval.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,24 @@ PyEval_GetCallStats(PyObject *self)
217217
#endif
218218

219219

220+
#ifdef WITH_THREAD
221+
#define GIL_REQUEST _Py_atomic_load_relaxed(&gil_drop_request)
222+
#else
223+
#define GIL_REQUEST 0
224+
#endif
225+
220226
/* This can set eval_breaker to 0 even though gil_drop_request became
221227
1. We believe this is all right because the eval loop will release
222228
the GIL eventually anyway. */
223229
#define COMPUTE_EVAL_BREAKER() \
224230
_Py_atomic_store_relaxed( \
225231
&eval_breaker, \
226-
_Py_atomic_load_relaxed(&gil_drop_request) | \
232+
GIL_REQUEST | \
227233
_Py_atomic_load_relaxed(&pendingcalls_to_do) | \
228234
pending_async_exc)
229235

236+
#ifdef WITH_THREAD
237+
230238
#define SET_GIL_DROP_REQUEST() \
231239
do { \
232240
_Py_atomic_store_relaxed(&gil_drop_request, 1); \
@@ -239,6 +247,8 @@ PyEval_GetCallStats(PyObject *self)
239247
COMPUTE_EVAL_BREAKER(); \
240248
} while (0)
241249

250+
#endif
251+
242252
/* Pending calls are only modified under pending_lock */
243253
#define SIGNAL_PENDING_CALLS() \
244254
do { \
@@ -387,7 +397,6 @@ PyEval_ReInitThreads(void)
387397

388398
#else
389399
static _Py_atomic_int eval_breaker = {0};
390-
static _Py_atomic_int gil_drop_request = {0};
391400
static int pending_async_exc = 0;
392401
#endif /* WITH_THREAD */
393402

@@ -1277,8 +1286,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
12771286
goto on_error;
12781287
}
12791288
}
1280-
if (_Py_atomic_load_relaxed(&gil_drop_request)) {
12811289
#ifdef WITH_THREAD
1290+
if (_Py_atomic_load_relaxed(&gil_drop_request)) {
12821291
/* Give another thread a chance */
12831292
if (PyThreadState_Swap(NULL) != tstate)
12841293
Py_FatalError("ceval: tstate mix-up");
@@ -1289,8 +1298,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
12891298
take_gil(tstate);
12901299
if (PyThreadState_Swap(tstate) != NULL)
12911300
Py_FatalError("ceval: orphan tstate");
1292-
#endif
12931301
}
1302+
#endif
12941303
/* Check for asynchronous exceptions. */
12951304
if (tstate->async_exc != NULL) {
12961305
x = tstate->async_exc;

0 commit comments

Comments
 (0)