diff options
author | Victor Stinner <vstinner@python.org> | 2021-03-10 19:00:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-10 19:00:46 (GMT) |
commit | 87f649a409da9d99682e78a55a83fc43225a8729 (patch) | |
tree | ecba0910f42f93dd6aa107ce4506a55f66249ec2 /Python/pylifecycle.c | |
parent | 9a9c11ad41d7887f3d6440e0f0e8966156d959b5 (diff) | |
download | cpython-87f649a409da9d99682e78a55a83fc43225a8729.zip cpython-87f649a409da9d99682e78a55a83fc43225a8729.tar.gz cpython-87f649a409da9d99682e78a55a83fc43225a8729.tar.bz2 |
bpo-43311: Create GIL autoTSSkey ealier (GH-24819)
At Python startup, call _PyGILState_Init() before
PyInterpreterState_New() which calls _PyThreadState_GET(). When
Python is built using --with-experimental-isolated-subinterpreters,
_PyThreadState_GET() uses autoTSSkey.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index d03c6c0..1b8c435 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -577,7 +577,7 @@ init_interp_create_gil(PyThreadState *tstate) _PyEval_FiniGIL(tstate->interp); /* Auto-thread-state API */ - status = _PyGILState_Init(tstate); + status = _PyGILState_SetTstate(tstate); if (_PyStatus_EXCEPTION(status)) { return status; } @@ -597,12 +597,19 @@ pycore_create_interpreter(_PyRuntimeState *runtime, const PyConfig *config, PyThreadState **tstate_p) { + /* Auto-thread-state API */ + PyStatus status = _PyGILState_Init(runtime); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + PyInterpreterState *interp = PyInterpreterState_New(); if (interp == NULL) { return _PyStatus_ERR("can't make main interpreter"); } + assert(_Py_IsMainInterpreter(interp)); - PyStatus status = _PyConfig_Copy(&interp->config, config); + status = _PyConfig_Copy(&interp->config, config); if (_PyStatus_EXCEPTION(status)) { return status; } |