mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-08-05 21:00:08 +03:00
lib/pool -- quick_cursor -- put connection back if there is an exception when connecting
This commit is contained in:
parent
4803870f90
commit
c54083a883
|
@ -127,8 +127,10 @@ class AbstractConnectionPool(object):
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def quick_cursor(self):
|
def quick_cursor(self):
|
||||||
"""A ContextManager for quickly getting a cursor"""
|
"""A ContextManager for quickly getting a cursor"""
|
||||||
|
try:
|
||||||
with self.getconn() as conn, conn.cursor() as cur:
|
with self.getconn() as conn, conn.cursor() as cur:
|
||||||
yield cur
|
yield cur
|
||||||
|
finally:
|
||||||
self.putconn(conn)
|
self.putconn(conn)
|
||||||
|
|
||||||
def _closeall(self):
|
def _closeall(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user