当前位置: 首页>>代码示例>>Python>>正文


Python Request.getWaiting方法代码示例

本文整理汇总了Python中DIRAC.RequestManagementSystem.Client.Request.Request.getWaiting方法的典型用法代码示例。如果您正苦于以下问题:Python Request.getWaiting方法的具体用法?Python Request.getWaiting怎么用?Python Request.getWaiting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.RequestManagementSystem.Client.Request.Request的用法示例。


在下文中一共展示了Request.getWaiting方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: export_putRequest

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import getWaiting [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)
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:55,代码来源:ReqManagerHandler.py

示例2: test04Operations

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import getWaiting [as 别名]
  def test04Operations( self ):
    """ operations arithmetic and state machine """
    req = Request()
    self.assertEqual( len( req ), 0 )

    transfer = Operation()
    transfer.Type = "ReplicateAndRegister"
    transfer.addFile( File( { "LFN" : "/a/b/c", "Status" : "Waiting" } ) )

    getWaiting = req.getWaiting()
    self.assertEqual( getWaiting["OK"], True )
    self.assertEqual( getWaiting["Value"], None )

    req.addOperation( transfer )
    self.assertEqual( len( req ), 1 )
    self.assertEqual( transfer.Order, req.Order )
    self.assertEqual( transfer.Status, "Waiting" )

    getWaiting = req.getWaiting()
    self.assertEqual( getWaiting["OK"], True )
    self.assertEqual( getWaiting["Value"], transfer )

    removal = Operation( { "Type" : "RemoveFile" } )
    removal.addFile( File( { "LFN" : "/a/b/c", "Status" : "Waiting" } ) )

    req.insertBefore( removal, transfer )

    getWaiting = req.getWaiting()
    self.assertEqual( getWaiting["OK"], True )
    self.assertEqual( getWaiting["Value"], removal )

    self.assertEqual( len( req ), 2 )
    self.assertEqual( [ op.Status for op in req ], ["Waiting", "Queued"] )
    self.assertEqual( req.subStatusList() , ["Waiting", "Queued"] )


    self.assertEqual( removal.Order, 0 )
    self.assertEqual( removal.Order, req.Order )

    self.assertEqual( transfer.Order, 1 )

    self.assertEqual( removal.Status, "Waiting" )
    self.assertEqual( transfer.Status, "Queued" )

    for subFile in removal:
      subFile.Status = "Done"
    removal.Status = "Done"

    self.assertEqual( removal.Status, "Done" )

    self.assertEqual( transfer.Status, "Waiting" )
    self.assertEqual( transfer.Order, req.Order )

    # # len, looping
    self.assertEqual( len( req ), 2 )
    self.assertEqual( [ op.Status for op in req ], ["Done", "Waiting"] )
    self.assertEqual( req.subStatusList() , ["Done", "Waiting"] )

    digest = req.toJSON()
    self.assertEqual( digest["OK"], True )

    getWaiting = req.getWaiting()
    self.assertEqual( getWaiting["OK"], True )
    self.assertEqual( getWaiting["Value"], transfer )
开发者ID:JanEbbing,项目名称:DIRAC,代码行数:66,代码来源:RequestTests.py

示例3: RequestTask

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import getWaiting [as 别名]

#.........这里部分代码省略.........
    updateRequest = self.requestClient.putRequest(
        self.request, useFailoverProxy=False, retryMainService=2)
    if not updateRequest["OK"]:
      self.log.error(updateRequest["Message"])
    return updateRequest

  def __call__(self):
    """ request processing """

    self.log.debug("about to execute request")
    gMonitor.addMark("RequestAtt", 1)

    # # setup proxy for request owner
    setupProxy = self.setupProxy()
    if not setupProxy["OK"]:
      self.request.Error = setupProxy["Message"]
      if 'has no proxy registered' in setupProxy["Message"]:
        self.log.error('Request set to Failed:', setupProxy["Message"])
        # If user is no longer registered, fail the request
        for operation in self.request:
          for opFile in operation:
            opFile.Status = 'Failed'
          operation.Status = 'Failed'
      else:
        self.log.error(setupProxy["Message"])
      return S_OK(self.request)
    shifter = setupProxy["Value"]["Shifter"]
    proxyFile = setupProxy["Value"]["ProxyFile"]

    error = None
    while self.request.Status == "Waiting":

      # # get waiting operation
      operation = self.request.getWaiting()
      if not operation["OK"]:
        self.log.error(operation["Message"])
        return operation
      operation = operation["Value"]
      self.log.info("executing operation #%s '%s'" % (operation.Order, operation.Type))

      # # and handler for it
      handler = self.getHandler(operation)
      if not handler["OK"]:
        self.log.error("unable to process operation %s: %s" % (operation.Type, handler["Message"]))
        # gMonitor.addMark( "%s%s" % ( operation.Type, "Fail" ), 1 )
        operation.Error = handler["Message"]
        break

      handler = handler["Value"]
      # # set shifters list in the handler
      handler.shifter = shifter
      # # and execute
      pluginName = self.getPluginName(self.handlersDict.get(operation.Type))
      if self.standalone:
        useServerCertificate = gConfig.useServerCertificate()
      else:
        # Always use server certificates if executed within an agent
        useServerCertificate = True
      try:
        if pluginName:
          gMonitor.addMark("%s%s" % (pluginName, "Att"), 1)
        # Always use request owner proxy
        if useServerCertificate:
          gConfigurationData.setOptionInCFG('/DIRAC/Security/UseServerCertificate', 'false')
        exe = handler()
        if useServerCertificate:
开发者ID:andresailer,项目名称:DIRAC,代码行数:70,代码来源:RequestTask.py


注:本文中的DIRAC.RequestManagementSystem.Client.Request.Request.getWaiting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。