def markasdone(self, job, success, elapsedtime, error=None):
""" log a job as being processed (either successfully or not) """
query = """
INSERT INTO modw_supremm.`process`
(jobid, process_version, process_timestamp, process_time) VALUES (%s, %s, NOW(), %s)
ON DUPLICATE KEY UPDATE process_version = %s, process_timestamp = NOW(), process_time = %s
"""
if error != None:
version = -1000 - error
else:
version = Accounting.PROCESS_VERSION if success else -1 * Accounting.PROCESS_VERSION
data = (job.job_pk_id, version, elapsedtime, version, elapsedtime)
if self.madcon == None:
self.madcon = getdbconnection(self.dbsettings, False)
cur = self.madcon.cursor()
try:
cur.execute(query, data)
except OperationalError:
logging.warning("Lost MySQL Connection. Attempting single reconnect")
self.madcon = getdbconnection(self.dbsettings, False)
cur = self.madcon.cursor()
cur.execute(query, data)
self.madcon.commit()
评论列表
文章目录