mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-08-03 11:50: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
10
lib/pool.py
10
lib/pool.py
|
@ -126,10 +126,12 @@ class AbstractConnectionPool(object):
|
|||
@property
|
||||
@contextmanager
|
||||
def quick_cursor(self):
|
||||
"""A ContextManager for quickly getting a cursor"""
|
||||
with self.getconn() as conn, conn.cursor() as cur:
|
||||
yield cur
|
||||
self.putconn(conn)
|
||||
"""A ContextManager for quickly getting a cursor"""
|
||||
try:
|
||||
with self.getconn() as conn, conn.cursor() as cur:
|
||||
yield cur
|
||||
finally:
|
||||
self.putconn(conn)
|
||||
|
||||
def _closeall(self):
|
||||
"""Close all connections.
|
||||
|
|
Loading…
Reference in New Issue
Block a user