本文整理汇总了Python中gaffer.manager.Manager.jobs方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.jobs方法的具体用法?Python Manager.jobs怎么用?Python Manager.jobs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gaffer.manager.Manager
的用法示例。
在下文中一共展示了Manager.jobs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sessions
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import jobs [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']