mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-08-05 12:50:09 +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
10
lib/pool.py
10
lib/pool.py
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user