summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-03-05 18:14:09 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-03-05 18:14:09 -0500
commit48b82aebc3cda2ae9638f0922eea646288b45c72 (patch)
treee495aea01e556b9e92bc8cd86c394b06662b898c
parent5299352ccfbceb121fa2b2f2e6f9e222149e7d15 (diff)
downloadsqlalchemy-48b82aebc3cda2ae9638f0922eea646288b45c72.tar.gz
- 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.
-rw-r--r--doc/build/changelog/changelog_09.rst7
-rw-r--r--lib/sqlalchemy/pool.py6
2 files changed, 10 insertions, 3 deletions
diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst
index 1591872cd..12b7c8583 100644
--- a/doc/build/changelog/changelog_09.rst
+++ b/doc/build/changelog/changelog_09.rst
@@ -15,6 +15,13 @@
: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
Fixed bug in association proxy where assigning an empty slice
diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py
index af9b8fcbc..59c1e614a 100644
--- a/lib/sqlalchemy/pool.py
+++ b/lib/sqlalchemy/pool.py
@@ -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