From 48b82aebc3cda2ae9638f0922eea646288b45c72 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 5 Mar 2014 18:14:09 -0500 Subject: - 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. --- lib/sqlalchemy/pool.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy') 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 -- cgit v1.2.1