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


Python Worker._start方法代码示例

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


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

示例1: f

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
    def f():
        s = Scheduler()
        s.listen(0)
        x = Worker(s.ip, s.port, ip='127.0.0.1')
        y = Worker(s.ip, s.port, ip='127.0.0.1')
        z = Worker(s.ip, s.port, ip='127.0.0.1')
        x.data['a'] = 1
        y.data['a'] = 2
        yield [x._start(), y._start(), z._start()]

        zz = rpc(ip=z.ip, port=z.port)
        yield zz.compute(function=dumps(inc),
                         args=dumps(('a',)),
                         who_has={'a': [x.address]},
                         key='b')
        assert z.data['b'] == 2

        if 'a' in z.data:
            del z.data['a']
        yield zz.compute(function=dumps(inc),
                         args=dumps(('a',)),
                         who_has={'a': [y.address]},
                         key='c')
        assert z.data['c'] == 3

        yield [x._close(), y._close(), z._close()]
        zz.close_streams()
开发者ID:simonkamronn,项目名称:distributed,代码行数:29,代码来源:test_worker.py

示例2: f

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
 def f():
     c = Center('127.0.0.1')
     c.listen(8007)
     w = Worker(c.ip, c.port, ip='127.0.0.1')
     yield w._start()
     assert isinstance(w.port, int)
     assert w.port > 1024
开发者ID:nagyistge,项目名称:dask-distributed,代码行数:9,代码来源:test_worker.py

示例3: test_worker_with_port_zero

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
def test_worker_with_port_zero():
    s = Scheduler()
    s.listen(8007)
    w = Worker(s.ip, s.port, ip='127.0.0.1')
    yield w._start()
    assert isinstance(w.port, int)
    assert w.port > 1024
开发者ID:simonkamronn,项目名称:distributed,代码行数:9,代码来源:test_worker.py

示例4: test_worker_death_timeout

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
def test_worker_death_timeout(s):
    with dask.config.set({'distributed.comm.timeouts.connect': '1s'}):
        yield s.close()
        w = Worker(s.address, death_timeout=1)
        yield w._start()

    yield gen.sleep(2)
    assert w.status == 'closed'
开发者ID:tomMoral,项目名称:distributed,代码行数:10,代码来源:test_worker.py

示例5: test_scheduler_file

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
def test_scheduler_file():
    with tmpfile() as fn:
        s = Scheduler(scheduler_file=fn)
        s.start(8009)
        w = Worker(scheduler_file=fn)
        yield w._start()
        assert set(s.workers) == {w.address}
        yield w._close()
        s.stop()
开发者ID:tomMoral,项目名称:distributed,代码行数:11,代码来源:test_worker.py

示例6: test_worker_with_port_zero

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
def test_worker_with_port_zero():
    s = Scheduler()
    s.start(8007)
    w = Worker(s.address)
    yield w._start()
    assert isinstance(w.port, int)
    assert w.port > 1024

    yield w._close()
开发者ID:tomMoral,项目名称:distributed,代码行数:11,代码来源:test_worker.py

示例7: f

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
    def f():
        c = Center(ip="127.0.0.1")
        c.listen(0)
        x = Worker(c.ip, c.port, ip="127.0.0.1")
        y = Worker(c.ip, c.port, ip="127.0.0.1")
        z = Worker(c.ip, c.port, ip="127.0.0.1")
        x.data["a"] = 1
        y.data["a"] = 2
        yield [x._start(), y._start(), z._start()]

        zz = rpc(ip=z.ip, port=z.port)
        yield zz.compute(function=inc, args=("a",), needed=["a"], who_has={"a": {x.address}}, key="b")
        assert z.data["b"] == 2

        yield zz.compute(function=inc, args=("a",), needed=["a"], who_has={"a": {y.address}}, key="c")
        assert z.data["c"] == 3

        yield [x._close(), y._close(), z._close()]
        zz.close_streams()
开发者ID:kevineriklee,项目名称:distributed,代码行数:21,代码来源:test_worker.py

示例8: g

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
    def g():
        c = Center('127.0.0.1', 8017)
        c.listen(c.port)
        a = Worker('127.0.0.1', 8018, c.ip, c.port, ncores=1)
        yield a._start()
        b = Worker('127.0.0.1', 8019, c.ip, c.port, ncores=1)
        yield b._start()

        while len(c.ncores) < 2:
            yield gen.sleep(0.01)

        try:
            yield f(c, a, b)
        finally:
            with ignoring(Exception):
                yield a._close()
            with ignoring(Exception):
                yield b._close()
            c.stop()
开发者ID:thrasibule,项目名称:distributed,代码行数:21,代码来源:test_worker.py

示例9: test_service_hosts_match_worker

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
def test_service_hosts_match_worker(s):
    pytest.importorskip('bokeh')
    from distributed.bokeh.worker import BokehWorker
    services = {('bokeh', 0): BokehWorker}
    for host in ['tcp://0.0.0.0', 'tcp://127.0.0.2']:
        w = Worker(s.address, services=services)
        yield w._start(host)

        sock = first(w.services['bokeh'].server._http._sockets.values())
        assert sock.getsockname()[0] == host.split('://')[1]
        yield w._close()
开发者ID:tomMoral,项目名称:distributed,代码行数:13,代码来源:test_worker.py

示例10: test_Executor

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
def test_Executor(c, s):
    with ThreadPoolExecutor(2) as e:
        w = Worker(s.ip, s.port, executor=e)
        assert w.executor is e
        yield w._start()

        future = c.submit(inc, 1)
        result = yield future
        assert result == 2

        assert e._threads  # had to do some work

        yield w._close()
开发者ID:tomMoral,项目名称:distributed,代码行数:15,代码来源:test_worker.py

示例11: test_avoid_memory_monitor_if_zero_limit

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
def test_avoid_memory_monitor_if_zero_limit(c, s):
    worker = Worker(s.address, loop=s.loop, memory_limit=0,
                    memory_monitor_interval=10)
    yield worker._start()
    assert type(worker.data) is dict
    assert 'memory' not in worker.periodic_callbacks

    future = c.submit(inc, 1)
    assert (yield future) == 2
    yield gen.sleep(worker.memory_monitor_interval / 1000)

    yield c.submit(inc, 2)  # worker doesn't pause

    yield worker._close()
开发者ID:tomMoral,项目名称:distributed,代码行数:16,代码来源:test_worker.py

示例12: test_worker_fds

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
def test_worker_fds(s):
    psutil = pytest.importorskip('psutil')
    yield gen.sleep(0.05)
    start = psutil.Process().num_fds()

    worker = Worker(s.address, loop=s.loop)
    yield worker._start()
    yield gen.sleep(0.1)
    middle = psutil.Process().num_fds()
    start = time()
    while middle > start:
        yield gen.sleep(0.01)
        assert time() < start + 1

    yield worker._close()

    start = time()
    while psutil.Process().num_fds() > start:
        yield gen.sleep(0.01)
        assert time() < start + 0.5
开发者ID:tomMoral,项目名称:distributed,代码行数:22,代码来源:test_worker.py

示例13: test_spill_to_disk

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
def test_spill_to_disk(e, s):
    np = pytest.importorskip('numpy')
    w = Worker(s.ip, s.port, loop=s.loop, memory_limit=1000)
    yield w._start()

    x = e.submit(np.random.randint, 0, 255, size=500, dtype='u1', key='x')
    yield _wait(x)
    y = e.submit(np.random.randint, 0, 255, size=500, dtype='u1', key='y')
    yield _wait(y)

    assert set(w.data) == {x.key, y.key}
    assert set(w.data.fast) == {x.key, y.key}

    z = e.submit(np.random.randint, 0, 255, size=500, dtype='u1', key='z')
    yield _wait(z)
    assert set(w.data) == {x.key, y.key, z.key}
    assert set(w.data.fast) == {y.key, z.key}
    assert set(w.data.slow) == {x.key}

    yield x._result()
    assert set(w.data.fast) == {x.key, z.key}
    assert set(w.data.slow) == {y.key}
开发者ID:simonkamronn,项目名称:distributed,代码行数:24,代码来源:test_worker.py

示例14: test_spill_to_disk

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
def test_spill_to_disk(c, s):
    np = pytest.importorskip('numpy')
    w = Worker(s.address, loop=s.loop, memory_limit=1200 / 0.6,
               memory_pause_fraction=None, memory_spill_fraction=None)
    yield w._start()

    x = c.submit(np.random.randint, 0, 255, size=500, dtype='u1', key='x')
    yield wait(x)
    y = c.submit(np.random.randint, 0, 255, size=500, dtype='u1', key='y')
    yield wait(y)

    assert set(w.data) == {x.key, y.key}
    assert set(w.data.fast) == {x.key, y.key}

    z = c.submit(np.random.randint, 0, 255, size=500, dtype='u1', key='z')
    yield wait(z)
    assert set(w.data) == {x.key, y.key, z.key}
    assert set(w.data.fast) == {y.key, z.key}
    assert set(w.data.slow) == {x.key} or set(w.data.slow) == {x.key, y.key}

    yield x
    assert set(w.data.fast) == {x.key, z.key}
    assert set(w.data.slow) == {y.key} or set(w.data.slow) == {x.key, y.key}
    yield w._close()
开发者ID:tomMoral,项目名称:distributed,代码行数:26,代码来源:test_worker.py

示例15: test_scheduler_address_config

# 需要导入模块: from distributed.worker import Worker [as 别名]
# 或者: from distributed.worker.Worker import _start [as 别名]
def test_scheduler_address_config(c, s):
    with dask.config.set({'scheduler-address': s.address}):
        worker = Worker(loop=s.loop)
        yield worker._start()
        assert worker.scheduler.address == s.address
    yield worker._close()
开发者ID:tomMoral,项目名称:distributed,代码行数:8,代码来源:test_worker.py


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