mirror of
https://github.com/python/cpython.git
synced 2025-07-19 17:25:54 +00:00
Issue #9901: Destroying the GIL in Py_Finalize() can fail if some other
threads are still running. Instead, reinitialize the GIL on a second call to Py_Initialize().
This commit is contained in:
parent
0646b4bb77
commit
b0b384b7c0
2 changed files with 12 additions and 5 deletions
|
@ -10,6 +10,10 @@ What's New in Python 3.2 Alpha 3?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #9901: Destroying the GIL in Py_Finalize() can fail if some other
|
||||||
|
threads are still running. Instead, reinitialize the GIL on a second
|
||||||
|
call to Py_Initialize().
|
||||||
|
|
||||||
- Issue #9252: PyImport_Import no longer uses a fromlist hack to return the
|
- Issue #9252: PyImport_Import no longer uses a fromlist hack to return the
|
||||||
module that was imported, but instead gets the module from sys.modules.
|
module that was imported, but instead gets the module from sys.modules.
|
||||||
|
|
||||||
|
|
|
@ -217,8 +217,15 @@ Py_InitializeEx(int install_sigs)
|
||||||
Py_FatalError("Py_Initialize: can't make first thread");
|
Py_FatalError("Py_Initialize: can't make first thread");
|
||||||
(void) PyThreadState_Swap(tstate);
|
(void) PyThreadState_Swap(tstate);
|
||||||
|
|
||||||
/* auto-thread-state API, if available */
|
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
|
/* We can't call _PyEval_FiniThreads() in Py_Finalize 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_Finalize multiple times. */
|
||||||
|
_PyEval_FiniThreads();
|
||||||
|
|
||||||
|
/* Auto-thread-state API */
|
||||||
_PyGILState_Init(interp, tstate);
|
_PyGILState_Init(interp, tstate);
|
||||||
#endif /* WITH_THREAD */
|
#endif /* WITH_THREAD */
|
||||||
|
|
||||||
|
@ -514,10 +521,6 @@ Py_Finalize(void)
|
||||||
|
|
||||||
PyGrammar_RemoveAccelerators(&_PyParser_Grammar);
|
PyGrammar_RemoveAccelerators(&_PyParser_Grammar);
|
||||||
|
|
||||||
#ifdef WITH_THREAD
|
|
||||||
_PyEval_FiniThreads();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Py_TRACE_REFS
|
#ifdef Py_TRACE_REFS
|
||||||
/* Display addresses (& refcnts) of all objects still alive.
|
/* Display addresses (& refcnts) of all objects still alive.
|
||||||
* An address can be used to find the repr of the object, printed
|
* An address can be used to find the repr of the object, printed
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue