]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed small issue in :class:`.SingletonThreadPool` where the current
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 5 Mar 2014 23:14:09 +0000 (18:14 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 5 Mar 2014 23:14:09 +0000 (18:14 -0500)
connection to be returned might get inadvertently cleaned out during
the "cleanup" process.  Patch courtesy jd23.

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/pool.py

index 1591872cdf0735fc42b4e5d86015126defab8377..12b7c8583698d1551c412a422b6cad4730366b28 100644 (file)
 .. changelog::
     :version: 0.9.4
 
+    .. change::
+        :tags: bug, pool
+
+        Fixed small issue in :class:`.SingletonThreadPool` where the current
+        connection to be returned might get inadvertently cleaned out during
+        the "cleanup" process.  Patch courtesy jd23.
+
     .. change::
         :tags: bug, ext, py3k
 
index af9b8fcbcae4d1ef25bccbf35c04595846ad62f0..59c1e614a2f8dc12b4a22a26c45bc198868e4336 100644 (file)
@@ -817,7 +817,7 @@ class SingletonThreadPool(Pool):
         self._all_conns.clear()
 
     def _cleanup(self):
-        while len(self._all_conns) > self.size:
+        while len(self._all_conns) >= self.size:
             c = self._all_conns.pop()
             c.close()
 
@@ -837,9 +837,9 @@ class SingletonThreadPool(Pool):
             pass
         c = self._create_connection()
         self._conn.current = weakref.ref(c)
-        self._all_conns.add(c)
-        if len(self._all_conns) > self.size:
+        if len(self._all_conns) >= self.size:
             self._cleanup()
+        self._all_conns.add(c)
         return c