Merge "Drop expired connections before retrieving from the queue"
This commit is contained in:
commit
679cdeb153
@ -123,6 +123,7 @@ class ConnectionPool(queue.Queue):
|
|||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def acquire(self):
|
def acquire(self):
|
||||||
self._trace_logger('Acquiring connection')
|
self._trace_logger('Acquiring connection')
|
||||||
|
self._drop_expired_connections()
|
||||||
try:
|
try:
|
||||||
conn = self.get(timeout=self._connection_get_timeout)
|
conn = self.get(timeout=self._connection_get_timeout)
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
@ -135,7 +136,6 @@ class ConnectionPool(queue.Queue):
|
|||||||
yield conn
|
yield conn
|
||||||
finally:
|
finally:
|
||||||
self._trace_logger('Releasing connection %s', id(conn))
|
self._trace_logger('Releasing connection %s', id(conn))
|
||||||
self._drop_expired_connections()
|
|
||||||
try:
|
try:
|
||||||
# super() cannot be used here because Queue in stdlib is an
|
# super() cannot be used here because Queue in stdlib is an
|
||||||
# old-style class
|
# old-style class
|
||||||
|
Loading…
Reference in New Issue
Block a user