mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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.
This commit is contained in:
parent
9a9c11ad41
commit
87f649a409
3 changed files with 28 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue