Changed PostgreSQL queries to use transaction() method
(wasn't closing transactions sometimes).
@@ -248,7 +248,7 @@ class PostgresApplicationRecorder(
Returns the maximum notification ID.
"""
try:
- c = self.datastore.get_connection().cursor()
+ with self.datastore.transaction() as c:
c.execute(self.select_max_notification_id_statement)
return c.fetchone()[0] or 0
except psycopg2.Error as e:
@@ -288,7 +288,7 @@ class PostgresProcessRecorder(
"WHERE application_name=%s"
)
try:
- c = self.datastore.get_connection().cursor()
+ with self.datastore.transaction() as c:
c.execute(statement, params)
return c.fetchone()[0] or 0
except psycopg2.Error as e:
