From: Mike Bayer Date: Wed, 5 Mar 2014 23:14:09 +0000 (-0500) Subject: - Fixed small issue in :class:`.SingletonThreadPool` where the current X-Git-Tag: rel_0_9_4~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48b82aebc3cda2ae9638f0922eea646288b45c72;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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. --- diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 1591872cdf..12b7c85836 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -14,6 +14,13 @@ .. 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 diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index af9b8fcbca..59c1e614a2 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