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


Python Scheduler.listen方法代码示例

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


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

示例1: g

# 需要导入模块: from distributed import Scheduler [as 别名]
# 或者: from distributed.Scheduler import listen [as 别名]
    def g():
        s = Scheduler(ip='127.0.0.1')
        done = s.start()
        s.listen(0)
        a = Worker('127.0.0.1', s.port, ncores=2, ip='127.0.0.1')
        yield a._start()
        b = Worker('127.0.0.1', s.port, ncores=1, ip=b_ip)
        yield b._start()

        start = time()
        try:
            while len(s.ncores) < 2:
                yield gen.sleep(0.01)
                if time() - start > 5:
                    raise Exception("Cluster creation timeout")

            yield f(s, a, b)
        finally:
            logger.debug("Closing out test cluster")
            for w in [a, b]:
                with ignoring(TimeoutError, StreamClosedError, OSError):
                    yield w._close()
                if os.path.exists(w.local_dir):
                    shutil.rmtree(w.local_dir)
            yield s.close()
开发者ID:lucashtnguyen,项目名称:distributed,代码行数:27,代码来源:utils_test.py

示例2: start_cluster

# 需要导入模块: from distributed import Scheduler [as 别名]
# 或者: from distributed.Scheduler import listen [as 别名]
def start_cluster(ncores):
    s = Scheduler(ip='127.0.0.1')
    s.listen(0)
    workers = [Worker(s.ip, s.port, ncores=v, ip=k) for k, v in ncores]

    IOLoop.current().add_callback(s.start)
    yield [w._start() for w in workers]

    start = time()
    while len(s.ncores) < len(ncores):
        yield gen.sleep(0.01)
        if time() - start > 5:
            raise Exception("Cluster creation timeout")
    raise gen.Return((s, workers))
开发者ID:lucashtnguyen,项目名称:distributed,代码行数:16,代码来源:utils_test.py

示例3: f

# 需要导入模块: from distributed import Scheduler [as 别名]
# 或者: from distributed.Scheduler import listen [as 别名]
    def f(c, a, b):
        s = Scheduler((c.ip, c.port), loop=loop)
        s.listen(0)
        yield s.sync_center()
        done = s.start()

        progress = TextProgressBar([], scheduler=(s.ip, s.port), start=False,
                                   interval=0.01)
        yield progress.listen()

        assert progress.status == 'finished'
        check_bar_completed(capsys)

        s.close()
        yield done
开发者ID:lucashtnguyen,项目名称:distributed,代码行数:17,代码来源:test_progressbar.py

示例4: run_scheduler

# 需要导入模块: from distributed import Scheduler [as 别名]
# 或者: from distributed.Scheduler import listen [as 别名]
def run_scheduler(q, center_port=None, **kwargs):
    from distributed import Scheduler
    from tornado.ioloop import IOLoop, PeriodicCallback
    import logging
    IOLoop.clear_instance()
    loop = IOLoop(); loop.make_current()
    PeriodicCallback(lambda: None, 500).start()
    logging.getLogger("tornado").setLevel(logging.CRITICAL)

    center = ('127.0.0.1', center_port) if center_port else None
    scheduler = Scheduler(center=center, **kwargs)
    scheduler.listen(0)
    done = scheduler.start(0)

    q.put(scheduler.port)
    try:
        loop.start()
    finally:
        loop.close(all_fds=True)
开发者ID:danring,项目名称:distributed,代码行数:21,代码来源:utils_test.py


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