summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/pylifecycle.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 9ac5630..9ae03d4 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -578,12 +578,14 @@ init_interp_settings(PyInterpreterState *interp,
interp->feature_flags |= Py_RTFLAGS_MULTI_INTERP_EXTENSIONS;
}
+ /* We check "gil" in init_interp_create_gil(). */
+
return _PyStatus_OK();
}
static PyStatus
-init_interp_create_gil(PyThreadState *tstate, int own_gil)
+init_interp_create_gil(PyThreadState *tstate, int gil)
{
PyStatus status;
@@ -598,6 +600,15 @@ init_interp_create_gil(PyThreadState *tstate, int own_gil)
return status;
}
+ int own_gil;
+ switch (gil) {
+ case PyInterpreterConfig_DEFAULT_GIL: own_gil = 0; break;
+ case PyInterpreterConfig_SHARED_GIL: own_gil = 0; break;
+ case PyInterpreterConfig_OWN_GIL: own_gil = 1; break;
+ default:
+ return _PyStatus_ERR("invalid interpreter config 'gil' value");
+ }
+
/* Create the GIL and take it */
status = _PyEval_InitGIL(tstate, own_gil);
if (_PyStatus_EXCEPTION(status)) {
@@ -633,7 +644,7 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
// The main interpreter always has its own GIL.
- config.own_gil = 1;
+ config.gil = PyInterpreterConfig_OWN_GIL;
status = init_interp_settings(interp, &config);
if (_PyStatus_EXCEPTION(status)) {
return status;
@@ -647,7 +658,7 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
// XXX For now we do this before the GIL is created.
(void) _PyThreadState_SwapNoGIL(tstate);
- status = init_interp_create_gil(tstate, config.own_gil);
+ status = init_interp_create_gil(tstate, config.gil);
if (_PyStatus_EXCEPTION(status)) {
return status;
}
@@ -2057,7 +2068,7 @@ new_interpreter(PyThreadState **tstate_p, const PyInterpreterConfig *config)
goto error;
}
- status = init_interp_create_gil(tstate, config->own_gil);
+ status = init_interp_create_gil(tstate, config->gil);
if (_PyStatus_EXCEPTION(status)) {
goto error;
}