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


Python Client.close方法代码示例

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


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

示例1: test_error

# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import close [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()
开发者ID:OspreyX,项目名称:dask,代码行数:10,代码来源:test_client.py

示例2: test_get_with_dill

# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import close [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()
开发者ID:OspreyX,项目名称:dask,代码行数:11,代码来源:test_client.py

示例3: test_get

# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import close [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()
开发者ID:OspreyX,项目名称:dask,代码行数:11,代码来源:test_client.py

示例4: test_multiple_clients

# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import close [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()
开发者ID:BabeNovelty,项目名称:dask,代码行数:22,代码来源:test_client.py

示例5: test_multiple_clients

# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import close [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()
开发者ID:OspreyX,项目名称:dask,代码行数:23,代码来源:test_client.py

示例6: test_register_collections

# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import close [as 别名]
def test_register_collections():
    try:
        import dask.bag as db
    except ImportError:
        return
    with scheduler_and_workers() as (s, (a, b)):
        c = Client(s.address_to_clients)

        b = db.from_sequence(range(5), npartitions=2).map(inc)
        assert not s.collections
        c.set_collection('mybag', b)
        assert 'mybag' in s.collections

        d = Client(s.address_to_clients)
        b2 = d.get_collection('mybag')

        assert (type(b) == type(b2) and
                b.npartitions == b2.npartitions)
        assert list(b) == list(b2)

        c.close()
        d.close()
开发者ID:OspreyX,项目名称:dask,代码行数:24,代码来源:test_client.py

示例7: range

# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import close [as 别名]
            args.bin_width, args.filter_bandwidth, args.theta, args.shift
    ):
        start_time = datetime.now()
        ds = xr.open_mfdataset(
            ['/scratch/pkittiwi/fg1p/binned_noise_map/bin{:.2f}MHz/'
             'fbw{:.2f}MHz/theta{:.1f}/shift{:d}/binned_noise_map_bin{:.2f}MHz_'
             'fbw{:.2f}MHz_theta{:.1f}_shift{:d}_{:03d}.nc'
             .format(bw, fbw, t, s, bw, fbw, t, s, i) for i in range(500)],
            concat_dim=noise_dim, chunks=chunks
        )
        ds_masked = ds.where(mask == 1)
        noise_var = ds_masked.var(dim=['x', 'y']).compute()
        da = noise_var.to_array().squeeze()
        del da['variable']
        da.attrs['bin_width'] = bw
        da.attrs['filter_bandwidth'] = fbw
        da.attrs['theta'] = t
        da.attrs['shift'] = s
        da.name = 'binned_noise_variance'
        output_file = '/scratch/pkittiwi/fg1p/binned_noise_variance/' \
                      'binned_noise_variance_bin{:.2f}MHz_fbw{:.2f}MHz_' \
                      'theta{:.1f}_shift{:d}.nc'.format(bw, fbw, t, s)
        da.to_netcdf(output_file)
        print(
            'Finish {:s}. Spent {:.5f} sec on this file'
            .format(output_file, (datetime.now() - start_time).total_seconds())
        )

    client.close()
    cluster.close()
开发者ID:piyanatk,项目名称:sim,代码行数:32,代码来源:calculate_noise_var_dask.py

示例8: test_status

# 需要导入模块: from dask.distributed import Client [as 别名]
# 或者: from dask.distributed.Client import close [as 别名]
def test_status():
    with scheduler_and_workers() as (s, (a, b)):
        c = Client(s.address_to_clients)

        assert c.scheduler_status() == 'OK'
        c.close()
开发者ID:OspreyX,项目名称:dask,代码行数:8,代码来源:test_client.py


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