lib/pool -- quick_cursor -- put connection back if there is an exception when connecting

This commit is contained in:
diabolo-dan 2016-09-19 21:29:00 +01:00
parent 4803870f90
commit c54083a883

View File

@ -126,10 +126,12 @@ class AbstractConnectionPool(object):
@property @property
@contextmanager @contextmanager
def quick_cursor(self): def quick_cursor(self):
"""A ContextManager for quickly getting a cursor""" """A ContextManager for quickly getting a cursor"""
with self.getconn() as conn, conn.cursor() as cur: try:
yield cur with self.getconn() as conn, conn.cursor() as cur:
self.putconn(conn) yield cur
finally:
self.putconn(conn)
def _closeall(self): def _closeall(self):
"""Close all connections. """Close all connections.