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


Python manager.Manager类代码示例

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


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

示例1: init1

def init1():
    m = Manager()
    m.start()
    ctl = Controller(m)
    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir)
    return m, ctl, testfile, config
开发者ID:adamchainz,项目名称:gaffer,代码行数:7,代码来源:test_controller.py

示例2: start_manager

def start_manager():
    http_endpoint = HttpEndpoint(uri="%s:%s" % (TEST_HOST, TEST_PORT))
    http_handler = HttpHandler(endpoints=[http_endpoint])
    m = Manager()
    m.start(apps=[http_handler])
    time.sleep(0.2)
    return m
开发者ID:alepharchives,项目名称:gaffer,代码行数:7,代码来源:test_http.py

示例3: test_start_multiple

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,代码行数:10,代码来源:test_manager.py

示例4: test_monitor

def test_monitor():
    m = Manager()
    monitored = []
    def cb(evtype, info):
        monitored.append((evtype, info))

    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    configa = ProcessConfig("a", cmd, args=args, cwd=wdir)
    m.load(configa)
    time.sleep(0.2)
    os_pid = m.running[1].os_pid
    m.monitor(cb, "a")

    def stop(handle):
        m.unmonitor(cb, "a")
        m.stop()

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

    m.run()
    assert len(monitored) >= 1
    res = monitored[0]
    assert res[0] == "stat"
    assert "cpu" in res[1]
    assert res[1]["os_pid"] == os_pid
开发者ID:adamchainz,项目名称:gaffer,代码行数:27,代码来源:test_manager.py

示例5: test_monitor

def test_monitor():
    m = Manager()
    monitored = []
    def cb(evtype, info):
        monitored.append((evtype, info))

    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    m.add_process("a", cmd, args=args, cwd=wdir)
    time.sleep(0.2)
    pid = m.running[1].pid
    m.monitor("a", cb)

    def stop(handle):
        m.unmonitor("a", cb)
        m.stop()

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

    m.run()
    assert len(monitored) >= 1
    res = monitored[0]
    assert res[0] == "stat"
    assert "cpu" in res[1]
    assert res[1]["pid"] == pid
开发者ID:tilgovi,项目名称:gaffer,代码行数:26,代码来源:test_manager.py

示例6: test_start_multiple

def test_start_multiple():
    m = Manager()
    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    m.add_process("dummy", cmd, args=args, cwd=wdir, numprocesses=2)
    state = m.get_process_state("dummy")

    assert len(state.running) == 2

    m.stop()

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

示例7: test_stats

def test_stats():
    m = Manager()
    monitored = []
    def cb(info):
        monitored.append(info)

    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("a", cmd, args=args, cwd=wdir)
    m.load(config)
    os_pid = m.running[1].os_pid

    chan = m.subscribe("STATS:default.a")
    chan.bind(cb)

    def stop(handle):
        chan.unbind(cb)
        m.stop()

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

    m.run()
    assert len(monitored) >= 1
    res = monitored[0]
    assert "cpu" in res
    assert res["os_pid"] == os_pid
开发者ID:adamchainz,项目名称:gaffer,代码行数:27,代码来源:test_channel.py

示例8: test_flapping

def test_flapping():
    m = Manager()
    m.start()
    states = []
    cmd, args, wdir = crash_cmd()

    # create flapping info object
    flapping = FlappingInfo(attempts=1., window=1, retry_in=0.1,
            max_retry=1)

    # load conf
    conf1 = ProcessConfig("crashing", cmd, args=args, cwd=wdir,
            flapping=flapping)
    conf2 = ProcessConfig("crashing2", cmd, args=args, cwd=wdir)
    m.load(conf1)
    m.load(conf2)

    time.sleep(0.2)

    def cb(handle):
        state = m._get_locked_state("crashing")
        states.append(state.stopped)
        state2 = m._get_locked_state("crashing2")
        states.append(state2.stopped)
        m.stop()

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

    assert states == [True, False]
开发者ID:adamchainz,项目名称:gaffer,代码行数:31,代码来源:test_manager.py

示例9: test_restart_manager

def test_restart_manager():
    results = []
    m = Manager()
    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir, numprocesses=4)
    m.load(config)
    results.append(m.pids("dummy"))

    def cb(manager):
        results.append(m.pids("dummy"))
        m.stop()

    m.restart()
    t = pyuv.Timer(m.loop)
    t.start(cb, 0.4, 0.0)
    m.run()

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

示例10: test_process_id

def test_process_id():
    m = Manager()
    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    m.add_process("dummy", cmd, args=args, cwd=wdir, numprocesses=4)
    state = m.get_process_state("dummy")

    processes = state.list_processes()
    assert isinstance(processes, list)

    p = processes[0]
    assert isinstance(p, Process)
    assert p.id == 1

    p = processes[2]
    assert p.id == 3

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

示例11: test_restart_manager

def test_restart_manager():
    results = []
    m = Manager()
    m.start()
    testfile, cmd, args, wdir = dummy_cmd()
    m.add_process("dummy", cmd, args=args, cwd=wdir, numprocesses=4)
    state = m.get_process_state("dummy")
    results.append(state.pids)

    def cb(manager):
        state = m.get_process_state("dummy")
        results.append(state.pids)
        m.stop()

    m.restart()
    t = pyuv.Timer(m.loop)
    t.start(cb, 0.4, 0.0)
    m.run()

    assert results[0] != results[1]
开发者ID:tilgovi,项目名称:gaffer,代码行数:20,代码来源:test_manager.py

示例12: test_simple

def test_simple():
    m = Manager()
    m.start()
    assert m.started == True

    def on_stop(manager):
        assert manager.started == False

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

示例13: test_multiple_handers

def test_multiple_handers():
    http_endpoint = HttpEndpoint(uri="%s:%s" % (TEST_HOST, TEST_PORT))
    http_endpoint2 = HttpEndpoint(uri="%s:%s" % (TEST_HOST, TEST_PORT2))
    http_handler = HttpHandler(endpoints=[http_endpoint, http_endpoint2])
    m = Manager()
    m.start(apps=[http_handler])
    time.sleep(0.2)

    s = Server("http://%s:%s" % (TEST_HOST, TEST_PORT), loop=m.loop)
    s2 = Server("http://%s:%s" % (TEST_HOST, TEST_PORT2), loop=m.loop)
    assert TEST_PORT != TEST_PORT2
    assert s.version == __version__
    assert s2.version == __version__

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

示例14: test_flapping

def test_flapping():
    m = Manager()
    m.start()
    states = []
    cmd, args, wdir = crash_cmd()
    flapping = FlappingInfo(attempts=1, window=1., retry_in=0.1,
            max_retry=1)
    m.add_process("crashing", cmd, args=args, cwd=wdir, flapping=flapping)
    m.add_process("crashing2", cmd, args=args, cwd=wdir)
    time.sleep(0.2)

    def cb(handle):
        state = m.get_process("crashing")
        states.append(state.stopped)
        state2 = m.get_process("crashing2")
        states.append(state2.stopped)
        m.stop()

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

    assert states == [True, False]
开发者ID:tilgovi,项目名称:gaffer,代码行数:23,代码来源:test_manager.py

示例15: test_group

def test_group():
    m = Manager()
    started = []
    stopped = []
    def cb(evtype, info):
        if evtype == "start":
            started.append(info['name'])
        elif evtype == "stop":
            stopped.append(info['name'])

    m.start()
    m.subscribe('start', cb)
    m.subscribe('stop', cb)
    testfile, cmd, args, wdir = dummy_cmd()
    m.add_process("ga:a", cmd, args=args, cwd=wdir, start=False)
    m.add_process("ga:b", cmd, args=args, cwd=wdir, start=False)
    m.add_process("gb:a", cmd, args=args, cwd=wdir, start=False)
    groups = sorted(m.get_groups())
    ga1 = m.get_group('ga')
    gb1 = m.get_group('gb')
    m.start_group("ga")
    m.stop_group("ga")
    time.sleep(0.2)
    m.remove_process("ga:a")
    ga2 = m.get_group('ga')
    m.stop_group("gb")

    def stop(handle):
        m.unsubscribe("start", cb)
        m.unsubscribe("stop", cb)
        m.stop()

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

    assert groups == ['ga', 'gb']
    assert ga1 == ['ga:a', 'ga:b']
    assert gb1 == ['gb:a']
    assert started == ['ga:a', 'ga:b']
    assert stopped == ['ga:a', 'ga:b', 'gb:a']
    assert ga2 == ['ga:b']
开发者ID:tilgovi,项目名称:gaffer,代码行数:42,代码来源:test_manager.py


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