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


Python Manager.stop_process方法代码示例

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


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

示例1: test_send_signal

# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import stop_process [as 别名]
def test_send_signal():
    m = Manager()
    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    m.add_process("dummy", cmd, args=args, cwd=wdir)
    time.sleep(0.2)
    state = m.get_process_state("dummy")
    processes = state.list_processes()
    m.send_signal("dummy", signal.SIGHUP)
    time.sleep(0.2)

    m.send_signal(processes[0].id, signal.SIGHUP)
    m.stop_process("dummy")

    def stop(handle):
        handle.stop()
        m.stop()

    t = pyuv.Timer(m.loop)
    t.start(stop, 0.8, 0.0)
    m.run()

    with open(testfile, 'r') as f:
        res = f.read()
        assert res == 'STARTHUPHUPQUITSTOP'
开发者ID:tilgovi,项目名称:gaffer,代码行数:27,代码来源:test_manager.py

示例2: test_start_stop_process

# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import stop_process [as 别名]
def test_start_stop_process():
    m = Manager()
    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    m.add_process("dummy", cmd, args=args, cwd=wdir)
    state = m.get_process_state("dummy")

    assert len(state.running) == 1

    m.stop_process("dummy")
    assert len(state.running) == 0

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

示例3: test_process_events

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

    def cb(ev, *args):
        emitted.append(ev)

    # subscribe to all events
    m.on('proc.dummy', cb)

    testfile, cmd, args, wdir = dummy_cmd()
    m.add_process("dummy", cmd, args=args, cwd=wdir)
    m.stop_process("dummy")

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

    assert 'proc.dummy.start' in emitted
    assert 'proc.dummy.spawn' in emitted
    assert 'proc.dummy.stop' in emitted
    assert 'proc.dummy.exit' in emitted
开发者ID:tilgovi,项目名称:gaffer,代码行数:25,代码来源:test_manager.py

示例4: test_process_exit_event

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

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

    # subscribe to all events
    m.on('proc.dummy.exit', cb)

    testfile, cmd, args, wdir = dummy_cmd()
    m.add_process("dummy", cmd, args=args, cwd=wdir)
    m.stop_process("dummy")

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

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

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

示例5: test_lookup_manager

# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import stop_process [as 别名]
def test_lookup_manager():

    # intiallize the lookupd server
    loop = pyuv.Loop.default_loop()
    r = Registry(loop)
    sock = bind_sockets(LOOKUPD_ADDR)
    io_loop = IOLoop(_loop=loop)
    server = http_server(io_loop, sock, registration_db=r)
    server.start()

    # subscribe to events
    emitted = []
    def cb(event, message):
        emitted.append((event, message))
    r.bind_all(cb)


    # start the manager with the HTTP API
    http_handler = HttpHandler(MockConfig(bind=GAFFERD_ADDR,
            lookupd_addresses=["http://%s" % LOOKUPD_ADDR]))
    m = Manager(loop=loop)
    m.start(apps=[http_handler])

    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir)
    m.load(config)
    m.stop_process(1)
    m.unload("dummy")

    t = pyuv.Timer(loop)

    def do_stop(h):
        server.stop()
        io_loop.close(True)

    def stop_server(m):
        t.start(do_stop, 0.4, 0.0)

    m.stop(stop_server)
    loop.run()

    assert len(emitted) == 7
    actions = [line[0] for line in emitted]
    assert list(actions) == ['add_node', 'identify', 'add_job', 'add_process',
            'remove_process', 'remove_job', 'remove_node']


    assert isinstance(emitted[0][1], GafferNode)
    assert isinstance(emitted[1][1], GafferNode)
    assert isinstance(emitted[2][1], dict)
    assert "job_name" in emitted[2][1]
    assert emitted[2][1]['job_name'] == "default.dummy"
    assert isinstance(emitted[3][1], dict)
    assert "job_name" in emitted[3][1]
    assert emitted[3][1]['job_name'] == "default.dummy"
    assert "pid" in emitted[3][1]
    assert emitted[3][1]['pid'] == 1
    assert isinstance(emitted[4][1], dict)
    assert "job_name" in emitted[4][1]
    assert emitted[4][1]['job_name'] == "default.dummy"
    assert "pid" in emitted[4][1]
    assert emitted[4][1]['pid'] == 1
    assert isinstance(emitted[5][1], dict)
    assert emitted[5][1]['job_name'] == "default.dummy"
    assert isinstance(emitted[6][1], GafferNode)
    assert emitted[6][1].sessions == {}
开发者ID:adamchainz,项目名称:gaffer,代码行数:68,代码来源:test_lookup.py


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