本文整理汇总了Python中gaffer.manager.Manager.get_process_state方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.get_process_state方法的具体用法?Python Manager.get_process_state怎么用?Python Manager.get_process_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gaffer.manager.Manager
的用法示例。
在下文中一共展示了Manager.get_process_state方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_flapping
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import get_process_state [as 别名]
def test_flapping():
m = Manager()
m.start()
cmd, args, wdir = crash_cmd()
flapping = FlappingInfo(attempts=1, window=1, retry_in=0.1, max_retry=2)
m.add_process("crashing", cmd, args=args, cwd=wdir, flapping=flapping)
state = m.get_process_state("crashing")
def cb(handle):
handle.stop()
assert state.stopped == True
t = pyuv.Timer(m.loop)
t.start(cb, 0.8, 0.8)
m.add_process("crashing2", cmd, args=args, cwd=wdir)
state = m.get_process_state("crashing2")
def cb1(handle):
handle.stop()
assert state.stopped == False
t = pyuv.Timer(m.loop)
t.start(cb1, 0.8, 0.8)
m.stop()
m.run()
示例2: test_send_signal
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import get_process_state [as 别名]
def test_send_signal():
m = Manager()
m.start()
testfile, cmd, args, wdir = dummy_cmd()
m.add_process("dummy", cmd, args=args, cwd=wdir)
time.sleep(0.2)
state = m.get_process_state("dummy")
processes = state.list_processes()
m.send_signal("dummy", signal.SIGHUP)
time.sleep(0.2)
m.send_signal(processes[0].id, signal.SIGHUP)
m.stop_process("dummy")
def stop(handle):
handle.stop()
m.stop()
t = pyuv.Timer(m.loop)
t.start(stop, 0.8, 0.0)
m.run()
with open(testfile, 'r') as f:
res = f.read()
assert res == 'STARTHUPHUPQUITSTOP'
示例3: test_ttin
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import get_process_state [as 别名]
def test_ttin():
m = Manager()
m.start()
testfile, cmd, args, wdir = dummy_cmd()
m.add_process("dummy", cmd, args=args, cwd=wdir, numprocesses=1)
state = m.get_process_state("dummy")
assert len(state.running) == 1
ret = m.ttin("dummy", 1)
assert ret == 2
time.sleep(0.2)
assert len(state.running) == 2
ret = m.ttin("dummy", 1)
assert ret == 3
time.sleep(0.2)
assert len(state.running) == 3
ret = m.ttin("dummy", 3)
assert ret == 6
time.sleep(0.2)
assert len(state.running) == 6
m.stop()
m.run()
示例4: test_simple_process
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import get_process_state [as 别名]
def test_simple_process():
m = Manager()
m.start()
testfile, cmd, args, wdir = dummy_cmd()
m.add_process("dummy", cmd, args=args, cwd=wdir, start=False)
state = m.get_process_state("dummy")
assert state.numprocesses == 1
assert state.name == "dummy"
assert state.cmd == cmd
assert state.settings['args'] == args
assert state.settings['cwd'] == wdir
m.remove_process("dummy")
assert m.get_process_state("dummy") == None
m.stop()
m.run()
示例5: test_start_multiple
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import get_process_state [as 别名]
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()
示例6: test_start_stop_process
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import get_process_state [as 别名]
def test_start_stop_process():
m = Manager()
m.start()
testfile, cmd, args, wdir = dummy_cmd()
m.add_process("dummy", cmd, args=args, cwd=wdir)
state = m.get_process_state("dummy")
assert len(state.running) == 1
m.stop_process("dummy")
assert len(state.running) == 0
m.stop()
m.run()
示例7: test_numprocesses
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import get_process_state [as 别名]
def test_numprocesses():
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")
assert len(state.running) == 4
state.numprocesses = 0
assert state.numprocesses == 0
m.manage_process("dummy")
time.sleep(0.2)
assert len(state.running) == 0
m.stop()
m.run()
示例8: test_process_id
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import get_process_state [as 别名]
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()
示例9: test_restart_manager
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import get_process_state [as 别名]
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]