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


Python Executor.submit方法代码示例

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


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

示例1: test_multiple_executors_restart

# 需要导入模块: from distributed import Executor [as 别名]
# 或者: from distributed.Executor import submit [as 别名]
def test_multiple_executors_restart(s, a, b):
    e1 = Executor((s.ip, s.port), start=False)
    yield e1._start()
    e2 = Executor((s.ip, s.port), start=False)
    yield e2._start()

    x = e1.submit(inc, 1)
    y = e2.submit(inc, 2)
    xx = yield x._result()
    yy = yield y._result()
    assert xx == 2
    assert yy == 3

    yield e1._restart()

    assert x.cancelled()
    assert y.cancelled()

    yield e1._shutdown(fast=True)
    yield e2._shutdown(fast=True)
开发者ID:simonkamronn,项目名称:distributed,代码行数:22,代码来源:test_worker_failure.py

示例2: test_framework_runs

# 需要导入模块: from distributed import Executor [as 别名]
# 或者: from distributed.Executor import submit [as 别名]
    def test_framework_runs(self):
        with MesosCluster() as cluster:
            time.sleep(2)
            driver = DistributedDriver().create_driver(DistributedScheduler)
            driver.start()
            time.sleep(5)

            expect(cluster).to(have_activated_slaves(1))
            expect(cluster).to(have_framework_name('distributed-framework'))

            # distributed test - this probably doesnt belong here
            executor = Executor('127.0.0.1:8787')
            A = executor.map(lambda x: x**2, range(10))
            B = executor.map(lambda x: -x, A)
            total = executor.submit(sum, B)
            expect(total.result()).to(equal(-285))
            driver.stop()
开发者ID:hussainsultan,项目名称:mesos-distributed,代码行数:19,代码来源:test_framework.py

示例3: f

# 需要导入模块: from distributed import Executor [as 别名]
# 或者: from distributed.Executor import submit [as 别名]
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False, loop=loop)
        yield e._start()

        remote_arrays = [[[e.submit(np.full, (2, 3, 4), i + j + k)
                            for i in range(2)]
                            for j in range(2)]
                            for k in range(4)]

        x = yield _futures_to_dask_array(remote_arrays, executor=e)
        assert x.chunks == ((2, 2, 2, 2), (3, 3), (4, 4))
        assert x.dtype == np.full((), 0).dtype

        assert isinstance(x, da.Array)
        expr = x.sum()
        result = yield e._get(expr.dask, expr._keys())
        assert isinstance(result[0], np.number)

        yield e._shutdown()
开发者ID:freeman-lab,项目名称:distributed,代码行数:21,代码来源:test_collections.py

示例4: count_words

# 需要导入模块: from distributed import Executor [as 别名]
# 或者: from distributed.Executor import submit [as 别名]
#!/home/vagrant/miniconda3/bin/python

import os
from distributed import Executor

def count_words(filename):
    with open(filename, "r", encoding = "latin-1") as f:
        data = f.read()

    return len(data.split(" "))


def remote_word_count():
    root_dir = "/enron/lay-k"

    word_count = 0
    for directory, subdir, filenames in os.walk(root_dir):
        for filename in filenames:
            word_count += count_words(os.path.join(directory, filename))

    return word_count


executor = Executor("127.0.0.1:8786")

words = executor.submit(remote_word_count)

print("\n\n Word Count on remote machine is: ", words.result())

开发者ID:shantnu,项目名称:Python-Awesome-Job,代码行数:30,代码来源:disty.py


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