本文整理汇总了Python中gaffer.manager.Manager.jobs_walk方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.jobs_walk方法的具体用法?Python Manager.jobs_walk怎么用?Python Manager.jobs_walk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gaffer.manager.Manager
的用法示例。
在下文中一共展示了Manager.jobs_walk方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_priority
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import jobs_walk [as 别名]
def test_priority():
m = Manager()
started = []
def cb(evtype, info):
started.append(info['name'])
m.start()
m.events.subscribe('start', cb)
testfile, cmd, args, wdir = dummy_cmd()
a = ProcessConfig("a", cmd, args=args, cwd=wdir)
b = ProcessConfig("b", cmd, args=args, cwd=wdir)
c = ProcessConfig("c", cmd, args=args, cwd=wdir)
m.load(a, start=False)
m.load(b, start=False)
m.load(c, start=False)
# start all processes
m.jobs_walk(lambda mgr, label: mgr.start_job(label))
def stop(handle):
m.events.unsubscribe("start", cb)
m.stop()
t = pyuv.Timer(m.loop)
t.start(stop, 0.4, 0.0)
m.run()
assert started == ["default.a", "default.b", "default.c"]
示例2: test_processes_stats
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import jobs_walk [as 别名]
def test_processes_stats():
def collect_cb(inf, m, name):
inf.append(m.stats(name))
m = Manager()
m.start()
testfile, cmd, args, wdir = dummy_cmd()
testfile1, cmd1, args1, wdir1 = dummy_cmd()
configa = ProcessConfig("a", cmd, args=args, cwd=wdir)
m.load(configa)
time.sleep(0.2)
infos = []
infos2 = []
m.jobs_walk(partial(collect_cb, infos))
configb = ProcessConfig("b", cmd, args=args, cwd=wdir)
m.load(configb)
m.jobs_walk(partial(collect_cb, infos2))
m.stop()
m.run()
assert len(infos) == 1
assert len(infos2) == 2
assert infos[0]['name'] == "default.a"
assert infos2[0]['name'] == "default.a"
assert infos2[1]['name'] == "default.b"
示例3: test_sessions
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import jobs_walk [as 别名]
def test_sessions():
m = Manager()
started = []
stopped = []
def cb(evtype, info):
if evtype == "start":
started.append(info['name'])
elif evtype == "stop":
stopped.append(info['name'])
start_job = lambda mgr, label: mgr.start_job(label)
stop_job = lambda mgr, label: mgr.stop_job(label)
m.start()
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 = m.sessions
ga1 = m.jobs('ga')
gb1 = m.jobs('gb')
m.jobs_walk(start_job, "ga")
m.jobs_walk(start_job, "gb")
ga2 = []
def rem_cb(h):
m.unload("a", sessionid="ga")
[ga2.append(name) for name in m.jobs('ga')]
t0 = pyuv.Timer(m.loop)
t0.start(rem_cb, 0.2, 0.0)
m.jobs_walk(stop_job, "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']