本文整理汇总了Python中DIRAC.RequestManagementSystem.Client.ReqClient.ReqClient.readRequestsForJobs方法的典型用法代码示例。如果您正苦于以下问题:Python ReqClient.readRequestsForJobs方法的具体用法?Python ReqClient.readRequestsForJobs怎么用?Python ReqClient.readRequestsForJobs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.RequestManagementSystem.Client.ReqClient.ReqClient
的用法示例。
在下文中一共展示了ReqClient.readRequestsForJobs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DataRecoveryAgent
# 需要导入模块: from DIRAC.RequestManagementSystem.Client.ReqClient import ReqClient [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.ReqClient.ReqClient import readRequestsForJobs [as 别名]
#.........这里部分代码省略.........
if job.inputFile:
lfnCache.append(job.inputFile)
if job.outputFiles:
lfnCache.extend(job.outputFiles)
break
except RuntimeError as e: # try again
self.log.error('+++++ Failure for job:', job.jobID)
self.log.error('+++++ Exception: ', str(e))
counter = 0
for lfnChunk in breakListIntoChunks(list(lfnCache), 200):
counter += 200
if counter % 1000 == 0:
self.log.notice('Getting FileInfo: %d/%d: %3.1fs' % (counter, len(jobs), float(time.time() - self.startTime)))
while True:
try:
reps = self.fcClient.exists(lfnChunk)
if not reps['OK']:
self.log.error('Failed to check file existence, try again...', reps['Message'])
raise RuntimeError('Try again')
statuses = reps['Value']
lfnExistence.update(statuses['Successful'])
break
except RuntimeError: # try again
pass
return lfnExistence
def setPendingRequests(self, jobs):
"""Loop over all the jobs and get requests, if any."""
for jobChunk in breakListIntoChunks(jobs.values(), 1000):
jobIDs = [job.jobID for job in jobChunk]
while True:
result = self.reqClient.readRequestsForJobs(jobIDs)
if result['OK']:
break
self.log.error('Failed to read requests', result['Message'])
# repeat
for jobID in result['Value']['Successful']:
request = result['Value']['Successful'][jobID]
requestID = request.RequestID
dbStatus = self.reqClient.getRequestStatus(requestID).get('Value', 'Unknown')
for job in jobChunk:
if job.jobID == jobID:
job.pendingRequest = dbStatus not in ('Done', 'Canceled')
self.log.notice('Found %s request for job %d' % ('pending' if job.pendingRequest else 'finished', jobID))
break
def checkAllJobs(self, jobs, tInfo, tasksDict=None, lfnTaskDict=None):
"""run over all jobs and do checks"""
fileJobDict = defaultdict(list)
counter = 0
nJobs = len(jobs)
self.setPendingRequests(jobs)
lfnExistence = self.getLFNStatus(jobs)
self.log.notice('Running over all the jobs')
for counter, job in enumerate(jobs.values()):
if counter % self.printEveryNJobs == 0:
self.log.notice('%d/%d: %3.1fs' % (counter, nJobs, float(time.time() - self.startTime)))
while True:
try:
if job.pendingRequest:
self.log.warn('Job has Pending requests:\n%s' % job)
break
job.checkFileExistence(lfnExistence)
if tasksDict and lfnTaskDict: