From ca48ded98deabf72fc3bd9d267dbbbc40c0dd706 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Mon, 23 Nov 2009 22:41:14 -0500 Subject: [PATCH] avoid 'no transaction in progress' warnings (Ticket #162) https://fedorahosted.org/koji/ticket/162 --- koji/db.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/koji/db.py b/koji/db.py index 0ad2be0d..18a68691 100644 --- a/koji/db.py +++ b/koji/db.py @@ -124,6 +124,13 @@ def connect(debug=False): # closed. This is safe to call multiple times. conn = _DBconn.conn try: + # Under normal circumstances, the last use of this connection + # will have issued a raw ROLLBACK to close the transaction. To + # avoid 'no transaction in progress' warnings (depending on postgres + # configuration) we open a new one here. + # Should there somehow be a transaction in progress, a second + # BEGIN will be a harmless no-op, though there may be a warning. + conn.cursor().execute('BEGIN') conn.rollback() return DBWrapper(conn, debug) except pgdb.Error: