connection to be returned might get inadvertently cleaned out during
the "cleanup" process. Patch courtesy jd23.
.. 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
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()
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