当前位置: 首页>>代码示例>>Python>>正文


Python Manager.fire方法代码示例

本文整理汇总了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"
开发者ID:treemo,项目名称:circuits,代码行数:28,代码来源:test_channel_selection.py

示例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()
开发者ID:billtsay,项目名称:win-demo-opcua,代码行数:27,代码来源:test_dynamic_handlers.py

示例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()
开发者ID:billtsay,项目名称:win-demo-opcua,代码行数:16,代码来源:test_dynamic_handlers.py

示例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()
开发者ID:billtsay,项目名称:win-demo-opcua,代码行数:18,代码来源:test_loader.py

示例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()
开发者ID:dlobue,项目名称:arke,代码行数:32,代码来源:test.py

示例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()
开发者ID:geodelic,项目名称:arke,代码行数:32,代码来源:test.py


注:本文中的circuits.Manager.fire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。