avoid 'no transaction in progress' warnings (Ticket #162)

https://fedorahosted.org/koji/ticket/162
This commit is contained in:
Mike McLean 2009-11-23 22:41:14 -05:00
parent c015419bad
commit ca48ded98d

View file

@ -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: