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


Python test_manager.dummy_cmd函数代码示例

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


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

示例1: test_manager_hooks

def test_manager_hooks():
    hooks = create_hooks(['load', 'unload', 'start', 'update', 'stop',
        'job.default.dummy.start', 'job.default.dummy.spawn',
        'job.default.dummy.stop', 'job.default.dummy.exit'])
    emitted = []
    loop = pyuv.Loop.default_loop()
    s = get_server(loop, emitted)
    s.start()
    m = Manager(loop=loop)
    m.start(apps=[WebHooks(hooks)])
    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir, numprocesses=1)
    m.load(config)
    m.manage("dummy")
    m.scale("dummy", 1)
    m.unload("dummy")

    t = pyuv.Timer(loop)

    def on_stop(manager):
        t.start(lambda h: s.stop(), 0.4, 0.0)

    m.stop(on_stop)

    m.run()
    assert ('load', 'default.dummy') in emitted
    assert ('start', 'default.dummy') in emitted
    assert ('update', 'default.dummy') in emitted
    assert ('stop', 'default.dummy') in emitted
    assert ('unload', 'default.dummy') in emitted
    assert ('job.default.dummy.start', 'default.dummy') in emitted
    assert ('job.default.dummy.spawn', 'default.dummy') in emitted
    assert ('job.default.dummy.stop', 'default.dummy') in emitted
    assert ('job.default.dummy.exit', 'default.dummy') in emitted
开发者ID:adamchainz,项目名称:gaffer,代码行数:34,代码来源:test_webhooks.py

示例2: 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

示例3: test_basic

def test_basic():
    emitted = []
    m = Manager()
    m.start()

    def cb(ev, msg):
        emitted.append((ev, msg['name']))

    # subscribe to all events
    chan = m.subscribe("EVENTS")
    chan.bind('.', cb)

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

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

    assert ('load', 'default.dummy') in emitted
    assert ('start', 'default.dummy') in emitted
    assert ('update', 'default.dummy') in emitted
    assert ('stop', 'default.dummy') in emitted
    assert ('unload', 'default.dummy') in emitted
开发者ID:adamchainz,项目名称:gaffer,代码行数:27,代码来源:test_channel.py

示例4: test_process_events

def test_process_events():
    emitted = []
    m = Manager()
    m.start()

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

    # subscribe to all events
    chan = m.subscribe("JOB:default.dummy")
    chan.bind_all(cb)

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

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

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

示例5: test_manager_hooks

def test_manager_hooks():
    hooks = create_hooks(['create', 'start', 'update', 'stop',
        'delete', 'proc.dummy.start', 'proc.dummy.spawn',
        'proc.dummy.stop', 'proc.dummy.exit'])
    emitted = []
    loop = pyuv.Loop.default_loop()
    s = get_server(loop, emitted)
    s.start()
    m = Manager(loop=loop)
    m.start(apps=[WebHooks(hooks)])
    testfile, cmd, args, wdir = dummy_cmd()
    m.add_process("dummy", cmd, args=args, cwd=wdir, numprocesses=4)
    m.ttin("dummy", 1)
    m.remove_process("dummy")
    time.sleep(0.2)

    def on_stop(manager):
        s.stop()

    m.stop(on_stop)
    m.run()
    assert ('create', 'dummy') in emitted
    assert ('start', 'dummy') in emitted
    assert ('update', 'dummy') in emitted
    assert ('stop', 'dummy') in emitted
    assert ('delete', 'dummy') in emitted
    assert ('proc.dummy.start', 'dummy') in emitted
    assert ('proc.dummy.spawn', 'dummy') in emitted
    assert ('proc.dummy.stop', 'dummy') in emitted
    assert ('proc.dummy.exit', 'dummy') in emitted
开发者ID:metawake,项目名称:gaffer,代码行数:30,代码来源:test_webhooks.py

示例6: test_simple_job

def test_simple_job():
    m, s, socket = init()

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

    # send a command
    cmd0 = socket.send_command("load", config.to_dict(), start=False)
    cmd1 = socket.send_command("jobs")

    results = []
    def do_events(h):
        results.append((len(m.jobs()), len(s.jobs()), s.jobs()[0]))

    def stop(h):
        h.close()
        socket.close()
        m.stop()

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

    assert cmd0.error() == None
    assert cmd1.error() == None
    assert results[0] == (1, 1, "default.dummy")
    assert cmd0.result() == {"ok": True}
    assert cmd1.result()["jobs"][0] == "default.dummy"
开发者ID:adamchainz,项目名称:gaffer,代码行数:30,代码来源:test_webchannel.py

示例7: test_remove_job

def test_remove_job():
    m, s, socket = init()
    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir)

    results = []
    def cb(event, cmd):
        jobs = m.jobs()
        results.append((cmd, jobs))

    socket.bind("command_success", cb)
    socket.send_command("load", config.to_dict(), start=False)
    socket.send_command("unload", "dummy")

    def stop(h):
        h.close()
        socket.close()
        m.stop()

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

    assert len(results) == 2
    cmd0, jobs0 = results[0]
    cmd1, jobs1 = results[1]

    assert cmd0.result()["ok"] == True
    assert cmd1.result()["ok"] == True
    assert len(jobs0) == 1
    assert jobs0[0] == "default.dummy"
    assert len(jobs1) == 0
开发者ID:adamchainz,项目名称:gaffer,代码行数:32,代码来源:test_webchannel.py

示例8: test_stat_events_refcount

def test_stat_events_refcount():
    loop = pyuv.Loop.default_loop()
    monitored = []
    def cb(evtype, info):
        monitored.append((evtype, info))

    def cb2(evtype, info):
        monitored.append((evtype, info))

    testfile, cmd, args, cwd = dummy_cmd()
    p = Process(loop, "someid", "dummy", cmd, args=args,
        cwd=cwd)
    p.spawn()
    time.sleep(0.2)
    os_pid = p.os_pid
    p.monitor(cb)
    p.monitor(cb2)
    def stop(handle):
        p.unmonitor(cb)
        assert p._process_watcher.active == True
        assert p._process_watcher._refcount == 1
        p.unmonitor(cb2)
        assert p._process_watcher.active == False
        p.stop()

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

    assert len(monitored) >= 2
    res = monitored[0]
    assert res[0] == "stat"
    assert "cpu" in res[1]
开发者ID:david-caro,项目名称:gaffer,代码行数:33,代码来源:test_process.py

示例9: 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

示例10: test_simple

def test_simple():
    exit_res = []
    def exit_cb(process, return_code, term_signal):
        exit_res.append(process)


    loop = pyuv.Loop.default_loop()
    testfile, cmd, args, cwd = dummy_cmd()
    p = Process(loop, "someid", "dummy", cmd, args=args,
        cwd=cwd, on_exit_cb=exit_cb)

    assert p.pid == "someid"
    assert p.name == "dummy"
    assert p.cmd == cmd
    assert p.args == args
    assert cwd == cwd

    p.spawn()
    assert p.active == True

    time.sleep(0.2)
    p.stop()
    loop.run()
    assert p.active == False
    with open(testfile, 'r') as f:
        res = f.read()
        assert res == 'STARTQUITSTOP'

    assert len(exit_res) == 1
    assert exit_res[0].name == "dummy"
    assert exit_res[0].active == False
开发者ID:david-caro,项目名称:gaffer,代码行数:31,代码来源:test_process.py

示例11: test_pids

def test_pids():
    m, s = init()

    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir)
    s.load(config)
    time.sleep(0.2)

    job = s.get_job("dummy")
    assert isinstance(job, Job) == True

    pid = s.get_process(1)
    assert isinstance(pid, Process) == True
    assert pid.pid == 1
    assert pid.info.get('name') == "default.dummy"
    assert pid.name == "default.dummy"
    assert pid.os_pid == pid.info.get('os_pid')
    assert job.pids == [1]

    pid.stop()
    assert 1 not in m.running

    time.sleep(0.2)
    assert job.pids == [2]
    m.stop()
    m.run()
开发者ID:adamchainz,项目名称:gaffer,代码行数:26,代码来源:test_http.py

示例12: test_pids

def test_pids():
    m, s = init()

    testfile, cmd, args, wdir = dummy_cmd()
    p = s.add_process("dummy", cmd, args=args, cwd=wdir)
    time.sleep(0.2)

    p = s.get_process("dummy")
    assert isinstance(p, Process) == True

    pid = s.get_process(1)
    assert isinstance(pid, ProcessId) == True
    assert pid.pid == 1
    assert pid.process.get('name') == "dummy"

    assert p.pids == [1]

    pid.stop()
    assert 1 not in m.running

    time.sleep(0.2)
    assert p.pids == [2]


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

示例13: test_sessions

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

    m.events.subscribe('start', cb)
    m.events.subscribe('stop', cb)
    testfile, cmd, args, wdir = dummy_cmd()
    a = ProcessConfig("a", cmd, args=args, cwd=wdir)
    b = ProcessConfig("b", cmd, args=args, cwd=wdir)


    # load process config in different sessions
    m.load(a, sessionid="ga", start=False)
    m.load(b, sessionid="ga", start=False)
    m.load(a, sessionid="gb", start=False)

    sessions = s.sessions()

    ga1 = s.jobs('ga')
    gb1 = s.jobs('gb')

    start_app = lambda mgr, job: job.start()
    stop_app = lambda mgr, job: job.stop()

    s.jobs_walk(start_app, "ga")
    s.jobs_walk(start_app, "gb")

    ga2 = []
    def rem_cb(h):
        s.unload("a", sessionid="ga")
        [ga2.append(name) for name in s.jobs('ga')]

    t0 = pyuv.Timer(m.loop)
    t0.start(rem_cb, 0.2, 0.0)
    s.jobs_walk(stop_app, "gb")

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

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

    assert len(sessions) == 2
    assert sessions == ['ga', 'gb']
    assert ga1 == ['ga.a', 'ga.b']
    assert gb1 == ['gb.a']
    assert started == ['ga.a', 'ga.b', 'gb.a']
    assert stopped == ['gb.a', 'ga.a']
    assert ga2 == ['ga.b']
开发者ID:adamchainz,项目名称:gaffer,代码行数:58,代码来源:test_http.py

示例14: on_manager

 def on_manager(h):
     # start the manager with the HTTP API
     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")
     h.start(wait, 0.3, 0.0)
开发者ID:adamchainz,项目名称:gaffer,代码行数:9,代码来源:test_lookup.py

示例15: test_remove_job

def test_remove_job():
    m, s = init()
    testfile, cmd, args, wdir = dummy_cmd()
    config = ProcessConfig("dummy", cmd, args=args, cwd=wdir)
    s.load(config, start=False)
    assert s.jobs()[0] == "default.dummy"
    s.unload("dummy")
    assert len(s.jobs()) == 0
    assert len(m.jobs()) == 0
    assert len(m.sessions) == 0
    m.stop()
    m.run()
开发者ID:adamchainz,项目名称:gaffer,代码行数:12,代码来源:test_http.py


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