bpo-36356: Destroy the GIL at exit (GH-12453)

* Add _PyEval_FiniThreads2(). _PyEval_FiniThreads() now only clears
  the pending lock, whereas _PyEval_FiniThreads2() destroys the GIL.
* pymain_free() now calls _PyEval_FiniThreads2().
* Py_FinalizeEx() now calls _PyEval_FiniThreads().
This commit is contained in:
Victor Stinner 2019-04-29 11:15:56 +02:00 committed by GitHub
parent 7a5a1cfe04
commit b36e5d627d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 18 deletions

View file

@ -188,8 +188,19 @@ 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;
@ -197,11 +208,6 @@ _PyEval_FiniThreads(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