Commit 1d9b57ff authored by Denis Bilenko's avatar Denis Bilenko

examples/psycopg2_pool.py: move closeall() up

That way generic pool methods are grouped together.
parent 2229f9e4
......@@ -50,6 +50,14 @@ class DatabaseConnectionPool(object):
def put(self, item):
self.pool.put(item)
def closeall(self):
while not self.pool.empty():
conn = self.pool.get_nowait()
try:
conn.close()
except Exception:
pass
@contextlib.contextmanager
def connection(self):
conn = self.get()
......@@ -98,14 +106,6 @@ class DatabaseConnectionPool(object):
return
return conn
def closeall(self):
while not self.pool.empty():
conn = self.pool.get_nowait()
try:
conn.close()
except Exception:
pass
def execute(self, *args, **kwargs):
with self.cursor() as cursor:
cursor.execute(*args, **kwargs)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment