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


Python Manager._get_locked_state方法代码示例

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


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

示例1: test_scalein

# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import _get_locked_state [as 别名]
def test_scalein():
    m = Manager()
    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir, numprocesses=1)
    m.load(config)
    state = m._get_locked_state("dummy")

    assert len(state.running) == 1
    ret = m.scale("dummy", 1)
    assert ret == 2

    time.sleep(0.2)
    assert len(state.running) == 2

    ret = m.scale("dummy", 1)
    assert ret == 3

    time.sleep(0.2)
    assert len(state.running) == 3


    ret = m.scale("dummy", 3)
    assert ret == 6

    time.sleep(0.2)
    assert len(state.running) == 6

    m.stop()
    m.run()
开发者ID:adamchainz,项目名称:gaffer,代码行数:32,代码来源:test_manager.py

示例2: test_start_multiple

# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import _get_locked_state [as 别名]
def test_start_multiple():
    m = Manager()
    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir, numprocesses=2)
    m.load(config)
    state = m._get_locked_state("dummy")
    assert len(state.running) == 2
    m.stop()
    m.run()
开发者ID:adamchainz,项目名称:gaffer,代码行数:12,代码来源:test_manager.py

示例3: test_simple_job

# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import _get_locked_state [as 别名]
def test_simple_job():
    m = Manager()
    m.start()
    testfile, cmd, args, wdir = dummy_cmd()

    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir)

    m.load(config, start=False)
    state = m._get_locked_state("dummy")

    assert state.numprocesses == 1
    assert state.name == "default.dummy"
    assert state.cmd == cmd
    assert state.config['args'] == args
    assert state.config['cwd'] == wdir

    m.unload("dummy")

    with pytest.raises(ProcessError):
        m._get_locked_state("dummy")

    m.stop()
    m.run()
开发者ID:adamchainz,项目名称:gaffer,代码行数:25,代码来源:test_manager.py

示例4: test_start_stop_job

# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import _get_locked_state [as 别名]
def test_start_stop_job():
    res = []
    m = Manager()
    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir)
    m.load(config)
    state = m._get_locked_state("dummy")
    res.append(len(state.running))
    m.stop_job("dummy")
    res.append(len(state.running))
    m.stop()
    m.run()

    assert res == [1, 0]
开发者ID:adamchainz,项目名称:gaffer,代码行数:17,代码来源:test_manager.py

示例5: test_process_commit

# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import _get_locked_state [as 别名]
def test_process_commit():
    emitted = []
    m = Manager()
    m.start()

    def cb(ev, msg):
        emitted.append(msg)

    # subscribe to all events
    m.events.subscribe('job.default.dummy.exit', cb)

    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir, numprocesses=0)
    m.load(config)

    pids0 = m.pids()
    pid = m.commit("dummy", env={"BLAH": "test"})
    process = m.get_process(pid)
    pids1 = m.pids()

    state = m._get_locked_state("dummy")

    assert len(state.running) == 0
    assert state.numprocesses == 0
    assert len(state.running_out) == 1


    m.unload("dummy")

    time.sleep(0.2)
    m.stop()
    m.run()

    assert pids0 == []
    assert pid == 1
    assert process.name == "default.dummy"
    assert process.pid == 1
    assert "BLAH" in process.env
    assert pids1 == [1]

    assert len(emitted) == 1
    assert len(emitted[0]) == 7

    msg = emitted[0]
    assert "exit_status" in msg
    assert msg['once'] == True
开发者ID:adamchainz,项目名称:gaffer,代码行数:48,代码来源:test_manager.py

示例6: test_numprocesses

# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import _get_locked_state [as 别名]
def test_numprocesses():
    m = Manager()
    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir, numprocesses=4)
    m.load(config)
    state = m._get_locked_state("dummy")

    assert len(state.running) == 4
    state.numprocesses = 0
    assert state.numprocesses == 0

    m.manage("dummy")
    time.sleep(0.2)
    assert len(state.running) == 0
    m.stop()
    m.run()
开发者ID:adamchainz,项目名称:gaffer,代码行数:19,代码来源:test_manager.py

示例7: test_process_id

# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import _get_locked_state [as 别名]
def test_process_id():
    m = Manager()
    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir, numprocesses=4)
    m.load(config)
    state = m._get_locked_state("dummy")

    res = []
    def cb(m, p):
        res.append(p.pid)

    res2 = [p.pid for p in m.list("dummy")]
    m.walk(cb, "dummy")
    m.stop()
    m.run()

    assert res == [1, 2, 3, 4]
    assert res == res2
开发者ID:adamchainz,项目名称:gaffer,代码行数:21,代码来源:test_manager.py


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