Skip to content

Commit dd6ffa3

Browse files
authored
Merge pull request #251 from jpwhite4/autocommit
Enable autocommit for markasdone.
2 parents 2683cc7 + 775c7f3 commit dd6ffa3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/supremm/xdmodaccount.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,21 +302,21 @@ def markasdone(self, job, success, elapsedtime, error=None):
302302
data = (job.job_pk_id, version, elapsedtime, version, elapsedtime)
303303

304304
if self.madcon == None:
305-
self.madcon = getdbconnection(self.dbsettings, False)
305+
self.madcon = getdbconnection(self.dbsettings, False, {'autocommit': True})
306306

307307
cur = self.madcon.cursor()
308308

309309
try:
310310
cur.execute(query, data)
311-
except OperationalError:
312-
logging.warning("Lost MySQL Connection. Attempting single reconnect")
313-
self.madcon = getdbconnection(self.dbsettings, False)
311+
except OperationalError as e:
312+
logging.warning("Lost MySQL Connection. " + str(e))
313+
cur.close()
314+
self.madcon.close()
315+
logging.warning("Attempting reconnect")
316+
self.madcon = getdbconnection(self.dbsettings, False, {'autocommit': True})
314317
cur = self.madcon.cursor()
315318
cur.execute(query, data)
316319

317-
self.madcon.commit()
318-
319-
320320
class XDMoDArchiveCache(ArchiveCache):
321321
""" Helper class that adds job accounting records to the database """
322322

0 commit comments

Comments
 (0)