]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
attempting to fix reentrant condition that can happen with Queue.Queue
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 26 Jun 2006 04:32:34 +0000 (04:32 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 26 Jun 2006 04:32:34 +0000 (04:32 +0000)
CHANGES
lib/sqlalchemy/pool.py

diff --git a/CHANGES b/CHANGES
index 154829df8fc455d32a4acc4b92603494447e335a..a20782551f9ae694ab377402837658930063b8fb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -20,6 +20,7 @@ properly saving
 - fixed bug when specifying explicit module to mysql dialect
 - when QueuePool times out it raises a TimeoutError instead of
 erroneously making another connection
+- attempting to fix a rare hang that can occur with Queue.Queue
 
 0.2.3
 - overhaul to mapper compilation to be deferred.  this allows mappers
index b086aae9f6e4aae669c8fd549cb341c255f0711a..0feaf93bbb9bb5a08dd73c43e9dac6d7a09ce2d1 100644 (file)
@@ -15,8 +15,10 @@ import util, exceptions
 
 try:
     import thread
+    import threading
 except:
     import dummythread as thread
+    import dummythreading as threading
 
 proxies = {}
 
@@ -207,6 +209,15 @@ class QueuePool(Pool):
         Pool.__init__(self, **params)
         self._creator = creator
         self._pool = Queue.Queue(pool_size)
+
+        # modify the pool's mutex to be an RLock.  this is because a rare condition can
+        # occur where a ConnectionFairy's __del__ method gets called within the get() method
+        # of the Queue (and then tries to do a put() within the get()), causing a re-entrant hang.
+        # the RLock allows the mutex to be reentrant within that case.
+        self._pool.mutex = threading.RLock()
+        self._pool.not_empty = threading.Condition(self._pool.mutex)
+        self._pool.not_full = threading.Condition(self._pool.mutex)
+        
         self._overflow = 0 - pool_size
         self._max_overflow = max_overflow
         self._timeout = timeout