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


Python Request.create_from_jobinfo方法代码示例

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


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

示例1: _monitor_lrms_jobs

# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import create_from_jobinfo [as 别名]
    def _monitor_lrms_jobs(self):
        lrms_jobinfolist = self._platform.get_jobinfolist()
        now = cpyutils.eventloop.now()
        
        if lrms_jobinfolist is None:
            err_time = now - self._timestamp_joblist
            if err_time < _CONFIGURATION_MONITORING.PERIOD_MONITORING_JOBS_FAIL_GRACE:
                _LOGGER.debug("could not obtain the job list from the platform in the last %s seconds, but we are in grace time" % err_time)
                return
            
            _LOGGER.warning("could not obtain the job list from the platform in the last %s seconds" % err_time)
            lrms_jobinfolist = {}

        # Now we are updating the items in the lrms_jobinfo
        if self._lrms_joblist is None:
            _LOGGER.debug("first monitorisation of jobs in LRMS\n")
            self._lrms_joblist = JobList()
            for job in lrms_jobinfolist:
                self._lrms_joblist.append(Request.create_from_jobinfo(job))

        stored_j_ids = self._lrms_joblist.get_ids()
        for job_info in lrms_jobinfolist:
            j_id = job_info.job_id
            if j_id in stored_j_ids:
                job = self._lrms_joblist.get_by_id(j_id)
                job.update_info(job_info)
            else:
                _LOGGER.warning("job %s has just appeared" % j_id)
                self._lrms_joblist.append(Request.create_from_jobinfo(job_info))

        # First we are detecting the missing jobs
        job_ids = [ j.job_id for j in lrms_jobinfolist ]
        j_ids_to_delete = []

        for job in self._lrms_joblist:
            # Final states are SERVED, NOT_SERVED y DISSAPEARED, so if it the job is not in the observed list but it was in a temporary state (e.g. ATTENDED), it has dissapeared
            if (job.state not in [ Request.SERVED, Request.NOT_SERVED, Request.DISSAPEARED ]) and (job.job_id not in job_ids):
                job.set_state(Request.DISSAPEARED)

            # These are jobs that are kept because the job list is incremental and it is not substituted
            if (job.state in [ Request.NOT_SERVED, Request.SERVED, Request.DISSAPEARED ]) and ((now - job.timestamp_state) > _CONFIGURATION_MONITORING.COOLDOWN_SERVED_JOBS):
                j_ids_to_delete.append(job.job_id)
                
        for job_id in j_ids_to_delete:
            self._lrms_joblist.del_by_id(job_id)
                
        self._timestamp_joblist = now
开发者ID:amcaar,项目名称:clues,代码行数:49,代码来源:cluesd.py


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