本文整理汇总了Python中gaffer.manager.Manager.get_process方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.get_process方法的具体用法?Python Manager.get_process怎么用?Python Manager.get_process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gaffer.manager.Manager
的用法示例。
在下文中一共展示了Manager.get_process方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_process_commit
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import get_process [as 别名]
def test_process_commit():
emitted = []
m = Manager()
m.start()
def cb(ev, msg):
emitted.append(msg)
# subscribe to all events
m.events.subscribe('job.default.dummy.exit', cb)
testfile, cmd, args, wdir = dummy_cmd()
config = ProcessConfig("dummy", cmd, args=args, cwd=wdir, numprocesses=0)
m.load(config)
pids0 = m.pids()
pid = m.commit("dummy", env={"BLAH": "test"})
process = m.get_process(pid)
pids1 = m.pids()
state = m._get_locked_state("dummy")
assert len(state.running) == 0
assert state.numprocesses == 0
assert len(state.running_out) == 1
m.unload("dummy")
time.sleep(0.2)
m.stop()
m.run()
assert pids0 == []
assert pid == 1
assert process.name == "default.dummy"
assert process.pid == 1
assert "BLAH" in process.env
assert pids1 == [1]
assert len(emitted) == 1
assert len(emitted[0]) == 7
msg = emitted[0]
assert "exit_status" in msg
assert msg['once'] == True
示例2: test_process_stats
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import get_process [as 别名]
def test_process_stats():
m = Manager()
m.start()
testfile, cmd, args, wdir = dummy_cmd()
config = ProcessConfig("dummy", cmd, args=args, cwd=wdir)
m.load(config)
time.sleep(0.2)
info = m.stats("dummy")
info_by_id = m.get_process(1).info
os_pid = m.running[1].os_pid
m.stop()
m.run()
assert isinstance(info, dict)
assert isinstance(info_by_id, dict)
assert "os_pid" in info_by_id
assert info_by_id["os_pid"] == os_pid
assert info['name'] == "default.dummy"
assert len(info['stats']) == 1
assert info['stats'][0]['os_pid'] == info_by_id['os_pid']