本文整理汇总了Python中WMCore.Services.ReqMgr.ReqMgr.ReqMgr.getRequestByStatusFromMemoryCache方法的典型用法代码示例。如果您正苦于以下问题:Python ReqMgr.getRequestByStatusFromMemoryCache方法的具体用法?Python ReqMgr.getRequestByStatusFromMemoryCache怎么用?Python ReqMgr.getRequestByStatusFromMemoryCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Services.ReqMgr.ReqMgr.ReqMgr
的用法示例。
在下文中一共展示了ReqMgr.getRequestByStatusFromMemoryCache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WorkQueueManagerCleaner
# 需要导入模块: from WMCore.Services.ReqMgr.ReqMgr import ReqMgr [as 别名]
# 或者: from WMCore.Services.ReqMgr.ReqMgr.ReqMgr import getRequestByStatusFromMemoryCache [as 别名]
class WorkQueueManagerCleaner(BaseWorkerThread):
"""
Cleans expired items, updates element status.
"""
def __init__(self, queue, config):
"""
Initialise class members
"""
BaseWorkerThread.__init__(self)
self.forbiddenStatus = ["aborted", "aborted-completed", "force-complete", "completed"]
self.queue = queue
self.config = config
self.reqmgr2Svc = ReqMgr(self.config.General.ReqMgr2ServiceURL)
myThread = threading.currentThread()
daoFactory = DAOFactory(package="WMCore.WMBS",
logger=myThread.logger,
dbinterface=myThread.dbi)
self.finishedWorflowCheck = daoFactory(classname="Subscriptions.CountFinishedSubscriptionsByWorkflow")
def setup(self, parameters):
"""
Called at startup - introduce random delay
to avoid workers all starting at once
"""
t = random.randrange(self.idleTime)
self.logger.info('Sleeping for %d seconds before 1st loop' % t)
time.sleep(t)
@timeFunction
def algorithm(self, parameters):
"""
Check & expire negotiation failures
"""
self.queue.logger.info("Start updating & cleaning...")
try:
self.queue.performQueueCleanupActions()
# this will clean up whatever left over from above clean up.
# also if the wq replication has problem it won't delay the killing jobs in condor
# and updating wmbs status
# state lists which shouldn't be populated in wmbs. (To prevent creating work before WQE status updated)
# added completed status in the list due to the race condition
requests = self.reqmgr2Svc.getRequestByStatusFromMemoryCache(self.forbiddenStatus).getData()
results = self.finishedWorflowCheck.execute(workflowNames=requests)
requestsToKill = [reqInfo["workflow"] for reqInfo in results if reqInfo["open"] > 0]
self.queue.logger.info("Killing %d requests in WMBS ...", len(requestsToKill))
self.queue.killWMBSWorkflows(requestsToKill)
except Exception as ex:
self.queue.logger.exception("Error cleaning queue: %s", str(ex))
self.queue.logger.info("Finished updating & cleaning.")