本文整理汇总了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)
示例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()
示例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()
示例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())