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


Python Scheduler.sleep方法代码示例

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


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

示例1: body

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import sleep [as 别名]
 def body():
     try:
         while True:
             cls.process_msg()
             while len(cls.cmds) > 0 and (len(cls.pending_cmds) + len(cls.running_cmds)) < cls.max_cmds:
                 v, cmd_spec = cls.cmds.pop()
                 agent_id = cls.get_agent(v);
                 cmd_spec['agent_id'] = agent_id
                 cls.pending_cmds[agent_id] = cmd_spec
             yield from Scheduler.sleep()
     except Exception as e:
         logger.error(e)
开发者ID:wehu,项目名称:pydv,代码行数:14,代码来源:job.py

示例2: cmd

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import sleep [as 别名]
def cmd(*args):
    cmd_spec = {}
    cmd_spec['cmd'] = ' '.join(args)
    v = Scheduler.current
    if v.cwd:
        cmd_spec['dir'] = v.cwd
    JobEngine.push_cmd(v, cmd_spec)
    yield from Scheduler.sleep()
    exitcode = cmd_spec['exitcode']
    if exitcode == 0:
        logger.info("> command '{}' passed".format(cmd_spec['cmd']))
    else:
        errmsg = cmd_spec['errmsg'] + (" with exitcode {}".format(exitcode))
        logger.error("> command '{}' failed: {}".format(cmd_spec['cmd'], errmsg))
        raise Exception(errmsg)
开发者ID:wehu,项目名称:pydv,代码行数:17,代码来源:entity.py

示例3: build_needs

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import sleep [as 别名]
    def build_needs(self):
        n = self.node
        cv = Scheduler.current
        if n.color == 'black':
            return
        
        sg = needgraph.subgraph(n)
        for i in self.needs:
            if i.node.color == 'gray':
                i.add_waiter(n)
                n.wait_on.add(i.node)
                sg.remove_node(i.node)
                ssg = needgraph.subgraph(i.node)
                for j in ssg.nodes_iter():
                    sg.remove_node(j)
                    
        for i in sg.nodes_iter():
            if not i.color == 'black':
                i.color = 'gray'

        ns = set()
        def collect_nodes():
            for i in sg.nodes_iter():
                if sg.out_degree(i) == 0 and not i.color == 'black':
                    ns.add(i.ntt)
        collect_nodes()
        try:
            while len(ns) > 0:
                @join
                def body(s):
                    for i in ns:
                        @spawn(s)
                        def f(ii=i):
                            try:
                                yield from ii.build()
                            finally:
                                ii.node.color = 'black'
                                ns.remove(ii)
                                if sg.has_node(ii.node):
                                    sg.remove_node(ii.node)
                yield from body()
                collect_nodes()
            
            while len(n.wait_on) > 0:
                yield from Scheduler.sleep()

        except Exception as e:
            cv.exception = e
            for i in sg.nodes_iter():
                i.color = 'black'
                for j in i.waiter_nodes:
                    j.wait_on.remove(i)
                for v in i.waiters:
                    v.exception = cv.exception
                    Scheduler.wake(v)

        n.color = 'black'
            
        for i in n.waiter_nodes:
            i.wait_on.remove(n)

        for v in n.waiters:
            if cv.exception:
                v.exception = cv.exception
            Scheduler.wake(v)
            
        n.waiters.clear()
        n.waiter_nodes.clear()

        if cv.exception:
            raise cv.exception
开发者ID:wehu,项目名称:pydv,代码行数:73,代码来源:entity.py


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