[Python-checkins] r88011 - python/branches/py3k/Python/ceval_gil.h
antoine.pitrou
python-checkins at python.org
Sat Jan 15 12:37:12 CET 2011
Author: antoine.pitrou
Date: Sat Jan 15 12:37:11 2011
New Revision: 88011
Log:
Fix the GIL with subinterpreters. Hopefully this will allow mod_wsgi to work with 3.2.
(we need some tests for this)
Modified:
python/branches/py3k/Python/ceval_gil.h
Modified: python/branches/py3k/Python/ceval_gil.h
==============================================================================
--- python/branches/py3k/Python/ceval_gil.h (original)
+++ python/branches/py3k/Python/ceval_gil.h Sat Jan 15 12:37:11 2011
@@ -334,12 +334,15 @@
static void drop_gil(PyThreadState *tstate)
{
- /* NOTE: tstate is allowed to be NULL. */
if (!_Py_atomic_load_relaxed(&gil_locked))
Py_FatalError("drop_gil: GIL is not locked");
- if (tstate != NULL &&
- tstate != _Py_atomic_load_relaxed(&gil_last_holder))
- Py_FatalError("drop_gil: wrong thread state");
+ /* tstate is allowed to be NULL (early interpreter init) */
+ if (tstate != NULL) {
+ /* Sub-interpreter support: threads might have been switched
+ under our feet using PyThreadState_Swap(). Fix the GIL last
+ holder variable so that our heuristics work. */
+ _Py_atomic_store_relaxed(&gil_last_holder, tstate);
+ }
MUTEX_LOCK(gil_mutex);
_Py_ANNOTATE_RWLOCK_RELEASED(&gil_locked, /*is_write=*/1);
More information about the Python-checkins
mailing list