本文整理汇总了Python中circuits.Manager.fire方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.fire方法的具体用法?Python Manager.fire怎么用?Python Manager.fire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circuits.Manager
的用法示例。
在下文中一共展示了Manager.fire方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import fire [as 别名]
def test():
m = Manager() + A() + B() + C()
while m:
m.flush()
# Rely on Event.channels
x = m.fire(foo())
m.flush()
assert x.value == "Foo"
# Explicitly specify the channel
x = m.fire(foo(), "b")
m.flush()
assert x.value == "Hello World!"
# Explicitly specify a set of channels
x = m.fire(foo(), "a", "b")
m.flush()
assert x.value == ["Foo", "Hello World!"]
# Rely on self.channel
x = m.fire(foo(), "c")
m.flush()
m.flush()
assert x.value == "Bar"
示例2: test_removeHandler
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import fire [as 别名]
def test_removeHandler():
m = Manager()
m.start()
method = m.addHandler(on_foo)
waiter = pytest.WaitEvent(m, "foo")
x = m.fire(foo())
waiter.wait()
s = x.value
assert s == "Hello World!"
m.removeHandler(method)
waiter = pytest.WaitEvent(m, "foo")
x = m.fire(foo())
waiter.wait()
assert x.value is None
assert on_foo not in dir(m)
assert "foo" not in m._handlers
m.stop()
示例3: test_addHandler
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import fire [as 别名]
def test_addHandler():
m = Manager()
m.start()
m.addHandler(on_foo)
waiter = pytest.WaitEvent(m, "foo")
x = m.fire(foo())
waiter.wait()
s = x.value
assert s == "Hello World!"
m.stop()
示例4: test_main
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import fire [as 别名]
def test_main():
m = Manager()
loader = Loader(paths=[dirname(__file__)]).register(m)
m.start()
loader.load("app")
x = m.fire(test())
assert pytest.wait_for(x, "result")
s = x.value
assert s == "Hello World!"
m.stop()
示例5: Manager
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import fire [as 别名]
mylogger.addHandler(h)
m = Manager()
logging.debug("manager init")
m += Debugger()
logging.debug("debugger init + register")
# l = Logger()
# Config.__dict__['__metaclass__'] = HandlerMetaClass
# Config = HandlerMetaClass('Config', (_Config,), {})
c = Config(sys.argv[1])
print("\n\n")
print(c.name)
pprint(c._handlers)
print("\n\n")
# m += l
m += c
m.fire(Load(), target="config")
# while m: m.flush()
logging.debug("config init + register")
p = plugin_manager(paths=sys.argv[2])
logging.debug("pm init")
m += p
logging.debug("pm register")
# while m: m.flush()
# (Manager() + Logger() + Config(sys.argv[1]) + plugin_manager(paths=sys.argv[2])).run()
# while m: m.flush()
m.fire(Event(collect_plugin), "load", target="plugin_manager")
# p.load(collect_plugin)
logging.debug("pm load")
m.run()
示例6: Manager
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import fire [as 别名]
mylogger.addHandler(h)
m = Manager()
logging.debug('manager init')
m += Debugger()
logging.debug('debugger init + register')
#l = Logger()
#Config.__dict__['__metaclass__'] = HandlerMetaClass
#Config = HandlerMetaClass('Config', (_Config,), {})
c = Config(sys.argv[1])
print("\n\n")
print(c.name)
pprint(c._handlers)
print("\n\n")
#m += l
m += c
m.fire(Load(), target='config')
#while m: m.flush()
logging.debug('config init + register')
p = plugin_manager(paths=sys.argv[2])
logging.debug('pm init')
m += p
logging.debug('pm register')
#while m: m.flush()
#(Manager() + Logger() + Config(sys.argv[1]) + plugin_manager(paths=sys.argv[2])).run()
#while m: m.flush()
m.fire(Event(collect_plugin), 'load', target='plugin_manager')
#p.load(collect_plugin)
logging.debug('pm load')
m.run()