mirror of
https://github.com/python/cpython.git
synced 2025-07-16 15:55:18 +00:00
Revert "bpo-36356: Destroy the GIL at exit (GH-12453)" (GH613006)
This reverts commit b36e5d627d
.
This commit is contained in:
parent
b36e5d627d
commit
99fcc616d4
5 changed files with 18 additions and 26 deletions
|
@ -188,19 +188,8 @@ PyEval_InitThreads(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_PyEval_FiniThreads(void)
|
||||
{
|
||||
if (_PyRuntime.ceval.pending.lock != NULL) {
|
||||
PyThread_free_lock(_PyRuntime.ceval.pending.lock);
|
||||
_PyRuntime.ceval.pending.lock = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_PyEval_FiniThreads2(void)
|
||||
{
|
||||
if (!gil_created()) {
|
||||
return;
|
||||
|
@ -208,6 +197,11 @@ _PyEval_FiniThreads2(void)
|
|||
|
||||
destroy_gil();
|
||||
assert(!gil_created());
|
||||
|
||||
if (_PyRuntime.ceval.pending.lock != NULL) {
|
||||
PyThread_free_lock(_PyRuntime.ceval.pending.lock);
|
||||
_PyRuntime.ceval.pending.lock = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
|
||||
#include "Python-ast.h"
|
||||
#undef Yield /* undefine macro conflicting with <winbase.h> */
|
||||
#include "pycore_ceval.h" /* _PyEval_FiniThreads() */
|
||||
#include "pycore_context.h"
|
||||
#include "pycore_coreconfig.h"
|
||||
#include "pycore_context.h"
|
||||
#include "pycore_fileutils.h"
|
||||
#include "pycore_hamt.h"
|
||||
#include "pycore_pathconfig.h"
|
||||
|
@ -556,11 +555,12 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
|
|||
return _Py_INIT_ERR("can't make first thread");
|
||||
(void) PyThreadState_Swap(tstate);
|
||||
|
||||
/* Destroying the GIL in Py_FinalizeEx might fail when it is being
|
||||
referenced from another running thread (see bpo-9901).
|
||||
/* We can't call _PyEval_FiniThreads() in Py_FinalizeEx because
|
||||
destroying the GIL might fail when it is being referenced from
|
||||
another running thread (see issue #9901).
|
||||
Instead we destroy the previously created GIL here, which ensures
|
||||
that we can call Py_Initialize / Py_FinalizeEx multiple times. */
|
||||
_PyEval_FiniThreads2();
|
||||
_PyEval_FiniThreads();
|
||||
|
||||
/* Auto-thread-state API */
|
||||
_PyGILState_Init(runtime, interp, tstate);
|
||||
|
@ -1357,7 +1357,6 @@ Py_FinalizeEx(void)
|
|||
|
||||
call_ll_exitfuncs(runtime);
|
||||
|
||||
_PyEval_FiniThreads();
|
||||
_PyRuntime_Finalize();
|
||||
return status;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue