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

@ -1,6 +1,7 @@
/* Python interpreter main program */
#include "Python.h"
#include "pycore_ceval.h" /* _PyEval_FiniThreads2() */
#include "pycore_coreconfig.h"
#include "pycore_pylifecycle.h"
#include "pycore_pymem.h"
@ -525,15 +526,15 @@ done:
/* --- pymain_main() ---------------------------------------------- */
/* Free global variables which cannot be freed in Py_Finalize():
configuration options set before Py_Initialize() which should
remain valid after Py_Finalize(), since
Py_Initialize()-Py_Finalize() can be called multiple times. */
static void
pymain_free(void)
{
_PyImport_Fini2();
/* Free global variables which cannot be freed in Py_Finalize():
configuration options set before Py_Initialize() which should
remain valid after Py_Finalize(), since
Py_Initialize()-Py_Finalize() can be called multiple times. */
_PyEval_FiniThreads2();
_PyPathConfig_ClearGlobal();
_Py_ClearStandardStreamEncoding();
_Py_ClearArgcArgv();