diff --git a/src/DIRAC/WorkloadManagementSystem/DB/JobDB.py b/src/DIRAC/WorkloadManagementSystem/DB/JobDB.py index 540358b4ce2..e4507a230be 100755 --- a/src/DIRAC/WorkloadManagementSystem/DB/JobDB.py +++ b/src/DIRAC/WorkloadManagementSystem/DB/JobDB.py @@ -448,6 +448,9 @@ def setJobAttribute(self, jobID, attrName, attrValue, update=False, myDate=None, :return: S_OK/S_ERROR """ + if not jobID: + return S_OK() + if attrName not in self.jobAttributeNames: return S_ERROR(EWMSJMAN, "Request to set non-existing job attribute") @@ -505,6 +508,9 @@ def setJobAttributes(self, jobID, attrNames, attrValues, update=False, myDate=No :return: S_OK/S_ERROR """ + if not jobID: + return S_OK() + jobIDList = jobID if not isinstance(jobID, (list, tuple)): jobIDList = [jobID] diff --git a/src/DIRAC/WorkloadManagementSystem/DB/JobLoggingDB.py b/src/DIRAC/WorkloadManagementSystem/DB/JobLoggingDB.py index 3ed38f9bd7e..262a78cb6bf 100755 --- a/src/DIRAC/WorkloadManagementSystem/DB/JobLoggingDB.py +++ b/src/DIRAC/WorkloadManagementSystem/DB/JobLoggingDB.py @@ -91,14 +91,14 @@ def _get_date(date): # if JobID is a list, make a bulk insert if isinstance(jobID, list): - for i, _ in enumerate(jobID): - epoc = _date[i].replace(tzinfo=datetime.timezone.utc).timestamp() - MAGIC_EPOC_NUMBER - cmd = cmd + "(%d,'%s','%s','%s','%s',%f,'%s')," % ( - int(jobID[i]), - status[i], - minorStatus[i], - applicationStatus[:255], - str(_date[i]), + for jid, stat, mstat, appstat, dt in zip(jobID, status, minorStatus, applicationStatus, _date): + epoc = dt.replace(tzinfo=datetime.timezone.utc).timestamp() - MAGIC_EPOC_NUMBER + cmd += "(%d,'%s','%s','%s','%s',%f,'%s')," % ( + int(jid), + stat, + mstat, + appstat[:255], + str(dt), epoc, source[:32], ) diff --git a/src/DIRAC/WorkloadManagementSystem/Service/JobManagerHandler.py b/src/DIRAC/WorkloadManagementSystem/Service/JobManagerHandler.py index 10f6f62281e..ebb9b45de92 100755 --- a/src/DIRAC/WorkloadManagementSystem/Service/JobManagerHandler.py +++ b/src/DIRAC/WorkloadManagementSystem/Service/JobManagerHandler.py @@ -217,9 +217,9 @@ def export_submitJob(self, jobDesc): jobIDList, statusList, minorStatusList, date=timeStampList, source="JobManager" ) else: - for i, _ in enumerate(jobIDList): + for jobID, status, minorStatus, timeStamp in zip(jobIDList, statusList, minorStatusList, timeStampList): result = self.jobLoggingDB.addLoggingRecord( - jobIDList[i], statusList[i], minorStatusList[i], date=timeStampList[i], source="JobManager" + jobID, status, minorStatus, date=timeStamp, source="JobManager" ) # Set persistency flag