homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients amaury.forgeotdarc, pitrou
Date 2010年09月20日.11:42:06
SpamBayes Score 1.8922311e-06
Marked as misclassified No
Message-id <1284982928.81.0.161970660626.issue9901@psf.upfronthosting.co.za>
In-reply-to
Content
Moving the _PyEval_FiniThreads() call to Py_Initialize() solves the issue:
diff -r 9e49082da463 Python/pythonrun.c
--- a/Python/pythonrun.c Mon Sep 20 12:46:56 2010 +0200
+++ b/Python/pythonrun.c Mon Sep 20 13:41:47 2010 +0200
@@ -217,8 +217,15 @@ Py_InitializeEx(int install_sigs)
 Py_FatalError("Py_Initialize: can't make first thread");
 (void) PyThreadState_Swap(tstate);
 
- /* auto-thread-state API, if available */
 #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);
 #endif /* WITH_THREAD */
 
@@ -514,10 +521,6 @@ Py_Finalize(void)
 
 PyGrammar_RemoveAccelerators(&_PyParser_Grammar);
 
-#ifdef WITH_THREAD
- _PyEval_FiniThreads();
-#endif
-
 #ifdef Py_TRACE_REFS
 /* Display addresses (& refcnts) of all objects still alive.
 * An address can be used to find the repr of the object, printed
History
Date User Action Args
2010年09月20日 11:42:08pitrousetrecipients: + pitrou, amaury.forgeotdarc
2010年09月20日 11:42:08pitrousetmessageid: <1284982928.81.0.161970660626.issue9901@psf.upfronthosting.co.za>
2010年09月20日 11:42:07pitroulinkissue9901 messages
2010年09月20日 11:42:06pitroucreate

AltStyle によって変換されたページ (->オリジナル) /