Initialize autoTSSkey earlier. · python/cpython@7bdf5a4 · GitHub
Skip to content

Commit 7bdf5a4

Browse files
Initialize autoTSSkey earlier.
1 parent 4af2ecb commit 7bdf5a4

5 files changed

Lines changed: 81 additions & 73 deletions

File tree

Include/internal/pycore_pylifecycle.h

Lines changed: 1 addition & 1 deletion

Include/internal/pycore_pystate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ PyAPI_FUNC(PyStatus) _PyInterpreterState_Enable(_PyRuntimeState *runtime);
149149

150150
#ifdef HAVE_FORK
151151
extern PyStatus _PyInterpreterState_DeleteExceptMain(_PyRuntimeState *runtime);
152-
extern PyStatus _PyGILState_Reinit(_PyRuntimeState *runtime);
153152
extern void _PySignal_AfterFork(void);
154153
#endif
155154

Modules/posixmodule.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ PyOS_AfterFork_Child(void)
587587
PyStatus status;
588588
_PyRuntimeState *runtime = &_PyRuntime;
589589

590-
status = _PyGILState_Reinit(runtime);
590+
status = _PyRuntimeState_ReInitThreads(runtime);
591591
if (_PyStatus_EXCEPTION(status)) {
592592
goto fatal_error;
593593
}
@@ -611,11 +611,6 @@ PyOS_AfterFork_Child(void)
611611

612612
_PySignal_AfterFork();
613613

614-
status = _PyRuntimeState_ReInitThreads(runtime);
615-
if (_PyStatus_EXCEPTION(status)) {
616-
goto fatal_error;
617-
}
618-
619614
status = _PyInterpreterState_DeleteExceptMain(runtime);
620615
if (_PyStatus_EXCEPTION(status)) {
621616
goto fatal_error;

Python/pylifecycle.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -675,12 +675,7 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
675675
const PyConfig *src_config,
676676
PyThreadState **tstate_p)
677677
{
678-
/* Auto-thread-state API */
679-
PyStatus status = _PyGILState_Init(runtime);
680-
if (_PyStatus_EXCEPTION(status)) {
681-
return status;
682-
}
683-
678+
PyStatus status;
684679
PyInterpreterState *interp = PyInterpreterState_New();
685680
if (interp == NULL) {
686681
return _PyStatus_ERR("can't make main interpreter");
@@ -692,6 +687,12 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
692687
return status;
693688
}
694689

690+
/* Auto-thread-state API */
691+
status = _PyGILState_Init(interp);
692+
if (_PyStatus_EXCEPTION(status)) {
693+
return status;
694+
}
695+
695696
const _PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
696697
init_interp_settings(interp, &config);
697698

@@ -1795,10 +1796,8 @@ finalize_interp_clear(PyThreadState *tstate)
17951796
static void
17961797
finalize_interp_delete(PyInterpreterState *interp)
17971798
{
1798-
if (_Py_IsMainInterpreter(interp)) {
1799-
/* Cleanup auto-thread-state */
1800-
_PyGILState_Fini(interp);
1801-
}
1799+
/* Cleanup auto-thread-state */
1800+
_PyGILState_Fini(interp);
18021801

18031802
/* We can't call _PyEval_FiniGIL() here because destroying the GIL lock can
18041803
fail when it is being awaited by another running daemon thread (see

Python/pystate.c

Lines changed: 70 additions & 55 deletions

0 commit comments

Comments
 (0)