本文整理汇总了Python中DIRAC.RequestManagementSystem.Client.Request.Request.NotBefore方法的典型用法代码示例。如果您正苦于以下问题:Python Request.NotBefore方法的具体用法?Python Request.NotBefore怎么用?Python Request.NotBefore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.RequestManagementSystem.Client.Request.Request
的用法示例。
在下文中一共展示了Request.NotBefore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_putRequest
# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import NotBefore [as 别名]
def export_putRequest(cls, requestJSON):
""" put a new request into RequestDB
:param cls: class ref
:param str requestJSON: request serialized to JSON format
"""
requestDict = json.loads(requestJSON)
requestName = requestDict.get("RequestID", requestDict.get("RequestName", "***UNKNOWN***"))
request = Request(requestDict)
optimized = request.optimize()
if optimized.get("Value", False):
gLogger.debug("putRequest: request was optimized")
else:
gLogger.debug("putRequest: request unchanged", optimized.get("Message", "Nothing could be optimized"))
valid = cls.validate(request)
if not valid["OK"]:
gLogger.error("putRequest: request %s not valid: %s" % (requestName, valid["Message"]))
return valid
# If NotBefore is not set or user defined, we calculate its value
now = datetime.datetime.utcnow().replace(microsecond=0)
extraDelay = datetime.timedelta(0)
if request.Status not in Request.FINAL_STATES and (not request.NotBefore or request.NotBefore < now):
# We don't delay if it is the first insertion
if getattr(request, "RequestID", 0):
# If it is a constant delay, just set it
if cls.constantRequestDelay:
extraDelay = datetime.timedelta(minutes=cls.constantRequestDelay)
else:
# If there is a waiting Operation with Files
op = request.getWaiting().get("Value")
if op and len(op):
attemptList = [opFile.Attempt for opFile in op if opFile.Status == "Waiting"]
if attemptList:
maxWaitingAttempt = max([opFile.Attempt for opFile in op if opFile.Status == "Waiting"])
# In case it is the first attempt, extraDelay is 0
# maxWaitingAttempt can be None if the operation has no File, like the ForwardDiset
extraDelay = datetime.timedelta(
minutes=2 * math.log(maxWaitingAttempt) if maxWaitingAttempt else 0
)
request.NotBefore = now + extraDelay
gLogger.info(
"putRequest: request %s not before %s (extra delay %s)"
% (request.RequestName, request.NotBefore, extraDelay)
)
requestName = request.RequestName
gLogger.info("putRequest: Attempting to set request '%s'" % requestName)
return cls.__requestDB.putRequest(request)