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


Python ModelBroadcaster.stop方法代码示例

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


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

示例1: test_timeout

# 需要导入模块: from gnome.multi_model_broadcast import ModelBroadcaster [as 别名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 别名]
def test_timeout(secs, timeout, expected_runtime, valid_func):
    model = make_model()

    model_broadcaster = ModelBroadcaster(model,
                                         ('down', 'normal', 'up'),
                                         ('down', 'normal', 'up'))

    try:
        print '\nsleeping for {} secs...'.format(secs)
        if timeout is None:
            begin = time.time()
            res = model_broadcaster.cmd('sleep', {'secs': secs})
            end = time.time()
        else:
            begin = time.time()
            res = model_broadcaster.cmd('sleep', {'secs': secs},
                                        timeout=timeout)
            end = time.time()

        rt = end - begin

        # runtime duraton should be either:
        # - the expected response time plus a bit of overhead
        # - the expected timeout plus a bit of overhead
        print 'runtime: ', rt
        assert rt >= expected_runtime
        assert rt < expected_runtime + (expected_runtime * 0.06)

        assert valid_func(res)
    finally:
        model_broadcaster.stop()
开发者ID:NOAA-ORR-ERD,项目名称:PyGnome,代码行数:33,代码来源:test_model_multiproc.py

示例2: test_timeout_2_times

# 需要导入模块: from gnome.multi_model_broadcast import ModelBroadcaster [as 别名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 别名]
def test_timeout_2_times():
    model = make_model()

    model_broadcaster = ModelBroadcaster(model,
                                         ('down', 'normal', 'up'),
                                         ('down', 'normal', 'up'))

    try:
        #
        # First, we set a short timeout for a command, but a shorter command.
        # The command should succeed
        #
        secs, timeout, expected_runtime = 4, 5, 4
        print '\nsleeping for {} secs...'.format(secs)

        begin = time.time()
        res = model_broadcaster.cmd('sleep', {'secs': secs}, timeout=timeout)
        end = time.time()

        rt = end - begin

        assert rt >= expected_runtime
        assert rt < expected_runtime + (expected_runtime * 0.06)
        assert is_valid(res)

        #
        # Next, run a command with no timeout specified.  The timeout should
        # have reverted back to the default, and the command should succeed.
        #
        secs, expected_runtime = 9, 9
        print '\nsleeping for {} secs...'.format(secs)

        begin = time.time()
        res = model_broadcaster.cmd('sleep', {'secs': secs})
        end = time.time()

        rt = end - begin

        assert rt >= expected_runtime
        assert rt < expected_runtime + (expected_runtime * 0.06)
        assert is_valid(res)

    finally:
        model_broadcaster.stop()
开发者ID:NOAA-ORR-ERD,项目名称:PyGnome,代码行数:46,代码来源:test_model_multiproc.py

示例3: test_init

# 需要导入模块: from gnome.multi_model_broadcast import ModelBroadcaster [as 别名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 别名]
def test_init():
    model = make_model()

    with pytest.raises(TypeError):
        # no uncertainty arguments
        ModelBroadcaster(model)

    with pytest.raises(TypeError):
        # no spill amount uncertainties
        ModelBroadcaster(model,
                         ('down', 'normal', 'up'))

    model_broadcaster = ModelBroadcaster(model,
                                         ('down', 'normal', 'up'),
                                         ('down', 'normal', 'up'))

    try:
        assert hasattr(model_broadcaster, 'id')
    finally:
        model_broadcaster.stop()
开发者ID:NOAA-ORR-ERD,项目名称:PyGnome,代码行数:22,代码来源:test_model_multiproc.py

示例4: test_uncertainty_array_size

# 需要导入模块: from gnome.multi_model_broadcast import ModelBroadcaster [as 别名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 别名]
def test_uncertainty_array_size():
    model = make_model()

    model_broadcaster = ModelBroadcaster(model,
                                         ('down',),
                                         ('down',))

    try:
        assert len(model_broadcaster.tasks) == 1
    finally:
        model_broadcaster.stop()

    model_broadcaster = ModelBroadcaster(model,
                                         ('down', 'up'),
                                         ('down', 'up'))

    try:
        assert len(model_broadcaster.tasks) == 4
    finally:
        model_broadcaster.stop()

    model_broadcaster = ModelBroadcaster(model,
                                         ('down', 'normal', 'up'),
                                         ('down', 'normal', 'up'))

    try:
        assert len(model_broadcaster.tasks) == 9
    finally:
        model_broadcaster.stop()
开发者ID:NOAA-ORR-ERD,项目名称:PyGnome,代码行数:31,代码来源:test_model_multiproc.py

示例5: test_uncertainty_array_indexing

# 需要导入模块: from gnome.multi_model_broadcast import ModelBroadcaster [as 别名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 别名]
def test_uncertainty_array_indexing():
    model = make_model()

    model_broadcaster = ModelBroadcaster(model,
                                         ('down', 'normal', 'up'),
                                         ('down', 'normal', 'up'))

    try:
        res = model_broadcaster.cmd('get_wind_timeseries', {},
                                    ('down', 'down'))
        assert np.allclose([r[0] for r in res], 17.449237)

        res = model_broadcaster.cmd('get_spill_amounts', {}, ('down', 'down'))
        assert np.isclose(res[0], 333.33333)

        res = model_broadcaster.cmd('get_wind_timeseries', {}, ('up', 'up'))
        assert np.allclose([r[0] for r in res], 20.166224)

        res = model_broadcaster.cmd('get_spill_amounts', {}, ('up', 'up'))
        assert np.isclose(res[0], 1666.66666)
    finally:
        model_broadcaster.stop()
开发者ID:NOAA-ORR-ERD,项目名称:PyGnome,代码行数:24,代码来源:test_model_multiproc.py

示例6: test_weathering_output_only

# 需要导入模块: from gnome.multi_model_broadcast import ModelBroadcaster [as 别名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 别名]
def test_weathering_output_only():
    model = make_model(geojson_output=True)

    model_broadcaster = ModelBroadcaster(model,
                                         ('down', 'normal', 'up'),
                                         ('down', 'normal', 'up'))

    print '\nOutputter results:'
    res = model_broadcaster.cmd('get_outputters', {})

    assert not [o for r in res for o in r
                if not isinstance(o, WeatheringOutput)]

    print '\nStep results:'
    res = model_broadcaster.cmd('step', {})

    assert len(res) == 9

    # added a 'valid' flag to output
    assert [r.keys() for r in res
            if len(r.keys()) == 2
            and 'WeatheringOutput' in r]

    model_broadcaster.stop()
开发者ID:axiom-data-science,项目名称:PyGnome,代码行数:26,代码来源:test_model_multiproc.py

示例7: the

# 需要导入模块: from gnome.multi_model_broadcast import ModelBroadcaster [as 别名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 别名]
    print '\nGetting wind timeseries for all models:'
    pp.pprint(model_broadcaster.cmd('get_wind_timeseries', {}))

    print '\nGetting spill amounts for all models:'
    pp.pprint(model_broadcaster.cmd('get_spill_amounts', {}))

    print '\nGetting time & spill values for just the (down, down) model:'
    pp.pprint((model_broadcaster.cmd('get_wind_timeseries', {},
                                     ('down', 'down')),
               model_broadcaster.cmd('get_spill_amounts', {},
                                     ('down', 'down')),
               ))

    print '\nGetting time & spill values for just the (normal, normal) model:'
    pp.pprint((model_broadcaster.cmd('get_wind_timeseries', {},
                                     ('normal', 'normal')),
               model_broadcaster.cmd('get_spill_amounts', {},
                                     ('normal', 'normal')),
               ))

    print '\nGetting time & spill values for just the (up, up) model:'
    pp.pprint((model_broadcaster.cmd('get_wind_timeseries', {},
                                     ('up', 'up')),
               model_broadcaster.cmd('get_spill_amounts', {},
                                     ('up', 'up')),
               ))

    model_broadcaster.stop()
    print 'main(): stopped broadcaster.'
开发者ID:NOAA-ORR-ERD,项目名称:PyGnome,代码行数:31,代码来源:script_weathering_mp.py


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