本文整理汇总了Python中gaffer.manager.Manager.on方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.on方法的具体用法?Python Manager.on怎么用?Python Manager.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gaffer.manager.Manager
的用法示例。
在下文中一共展示了Manager.on方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_events
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import on [as 别名]
def test_events():
emitted = []
m = Manager()
m.start()
def cb(ev, msg):
emitted.append((ev, msg['name']))
# subscribe to all events
m.on('.', cb)
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)
m.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
示例2: test_process_events
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import on [as 别名]
def test_process_events():
emitted = []
m = Manager()
m.start()
def cb(ev, *args):
emitted.append(ev)
# subscribe to all events
m.on('proc.dummy', cb)
testfile, cmd, args, wdir = dummy_cmd()
m.add_process("dummy", cmd, args=args, cwd=wdir)
m.stop_process("dummy")
time.sleep(0.2)
m.stop()
m.run()
assert 'proc.dummy.start' in emitted
assert 'proc.dummy.spawn' in emitted
assert 'proc.dummy.stop' in emitted
assert 'proc.dummy.exit' in emitted
示例3: test_process_exit_event
# 需要导入模块: from gaffer.manager import Manager [as 别名]
# 或者: from gaffer.manager.Manager import on [as 别名]
def test_process_exit_event():
emitted = []
m = Manager()
m.start()
def cb(ev, msg):
emitted.append(msg)
# subscribe to all events
m.on('proc.dummy.exit', cb)
testfile, cmd, args, wdir = dummy_cmd()
m.add_process("dummy", cmd, args=args, cwd=wdir)
m.stop_process("dummy")
time.sleep(0.2)
m.stop()
m.run()
assert len(emitted) == 1
assert len(emitted[0]) == 6
msg = emitted[0]
assert "exit_status" in msg