本文整理汇总了Python中dask.distributed.Client.get方法的典型用法代码示例。如果您正苦于以下问题:Python Client.get方法的具体用法?Python Client.get怎么用?Python Client.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dask.distributed.Client
的用法示例。
在下文中一共展示了Client.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_keep_results
# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import get [as 别名]
def test_keep_results():
with scheduler_and_workers() as (s, (a, b)):
c = Client(s.address_to_clients)
assert c.get({'x': (inc, 1)}, 'x', keep_results=True) == 2
assert 'x' in a.data or 'x' in b.data
示例2: test_error
# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import get [as 别名]
def test_error():
with scheduler_and_workers() as (s, (a, b)):
c = Client(s.address_to_clients)
assert raises(TypeError,
lambda: c.get({'x': 1, 'y': (inc, 'x', 'x')}, 'y'))
assert 'y' not in s.data
c.close()
示例3: test_get_with_dill
# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import get [as 别名]
def test_get_with_dill():
with scheduler_and_workers() as (s, (a, b)):
c = Client(s.address_to_clients)
dsk = {'x': 1, 'y': (partial(add, 1), 'x')}
keys = 'y'
assert c.get(dsk, keys) == 2
c.close()
示例4: test_get
# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import get [as 别名]
def test_get():
with scheduler_and_workers() as (s, (a, b)):
c = Client(s.address_to_clients)
dsk = {'x': 1, 'y': (add, 'x', 'x'), 'z': (inc, 'y')}
keys = ['y', 'z']
assert c.get(dsk, keys) == [2, 3]
c.close()
示例5: test_multiple_clients
# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import get [as 别名]
def test_multiple_clients():
with scheduler_and_workers(1) as (s, (a,)):
c = Client(s.address_to_clients)
d = Client(s.address_to_clients)
assert c.get({'x': (inc, 1)}, 'x') == d.get({'x': (inc, 1)}, 'x')
pool = ThreadPool(2)
future1 = pool.apply_async(c.get,
args=({'x': 1, 'y': (inc, 'x')}, 'y'))
future2 = pool.apply_async(d.get,
args=({'a': 1, 'b': (inc, 'a')}, 'b'))
while not (future1.ready() and future2.ready()):
sleep(1e-6)
assert future1.get() == future2.get()
c.close()
d.close()
示例6: test_multiple_clients
# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import get [as 别名]
def test_multiple_clients():
with scheduler_and_workers(1) as (s, (a,)):
c = Client(s.address_to_clients)
d = Client(s.address_to_clients)
assert c.get({'x': (inc, 1)}, 'x') == d.get({'x': (inc, 1)}, 'x')
def sleep_inc(x):
sleep(0.5)
return x + 1
pool = ThreadPool(2)
future1 = pool.apply_async(c.get,
args=({'x': 1, 'y': (sleep_inc, 'x')}, 'y'))
future2 = pool.apply_async(d.get,
args=({'a': 1, 'b': (sleep_inc, 'a')}, 'b'))
assert future1.get() == future2.get()
c.close()
d.close()