summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 1cb0e4d..5ef2d3f 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -675,12 +675,7 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
const PyConfig *src_config,
PyThreadState **tstate_p)
{
- /* Auto-thread-state API */
- PyStatus status = _PyGILState_Init(runtime);
- if (_PyStatus_EXCEPTION(status)) {
- return status;
- }
-
+ PyStatus status;
PyInterpreterState *interp = PyInterpreterState_New();
if (interp == NULL) {
return _PyStatus_ERR("can't make main interpreter");
@@ -692,6 +687,12 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
return status;
}
+ /* Auto-thread-state API */
+ status = _PyGILState_Init(interp);
+ if (_PyStatus_EXCEPTION(status)) {
+ return status;
+ }
+
const _PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
init_interp_settings(interp, &config);
@@ -1795,10 +1796,8 @@ finalize_interp_clear(PyThreadState *tstate)
static void
finalize_interp_delete(PyInterpreterState *interp)
{
- if (_Py_IsMainInterpreter(interp)) {
- /* Cleanup auto-thread-state */
- _PyGILState_Fini(interp);
- }
+ /* Cleanup auto-thread-state */
+ _PyGILState_Fini(interp);
/* We can't call _PyEval_FiniGIL() here because destroying the GIL lock can
fail when it is being awaited by another running daemon thread (see