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


Python circuits.Manager类代码示例

本文整理汇总了Python中circuits.Manager的典型用法代码示例。如果您正苦于以下问题:Python Manager类的具体用法?Python Manager怎么用?Python Manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Manager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_tcp_lookup_failure

def test_tcp_lookup_failure(Poller, ipv6):
    m = Manager() + Poller()

    if ipv6:
        tcp_client = TCP6Client()
    else:
        tcp_client = TCPClient()
    client = Client() + tcp_client

    client.register(m)

    m.start()

    try:
        assert pytest.wait_for(client, "ready")

        client.fire(connect("foo", 1234))
        assert pytest.wait_for(
            client, "error", lambda obj, attr: isinstance(getattr(obj, attr), SocketError))
        if pytest.PLATFORM == "win32":
            assert client.error.errno == 11004
        else:
            assert client.error.errno in (EAI_NODATA, EAI_NONAME,)
    finally:
        m.stop()
开发者ID:eriol,项目名称:circuits,代码行数:25,代码来源:test_tcp.py

示例2: after_properties_set

    def after_properties_set(self):
        """ Run by Spring Python after all the JMS container's properties have
        been set.
        """

        for idx in range(self.concurrent_listeners):
            # Create as many Circuits managers as there are JMS listeners.
            manager = Manager()
            manager.start()

            # A pool of handler threads for each listener.
            handlers_pool = ThreadPool(self.handlers_per_listener)

            # Each manager gets assigned its own listener.
            listener = WebSphereMQListener()

            # Assign the listener and a debugger component to the manager.
            manager += listener
            manager += Debugger(logger=self.logger)

            listener.factory = self.factory
            listener.destination = self.destination
            listener.handler = self.handler
            listener.handlers_pool = handlers_pool
            listener.wait_interval = self.wait_interval
            listener.start()
开发者ID:ktan2020,项目名称:legacy-automation,代码行数:26,代码来源:listener.py

示例3: test_pipe

def test_pipe(Poller):
    m = Manager() + Poller()

    a, b = Pipe("a", "b")
    a.register(m)
    b.register(m)

    a = Client(channel=a.channel).register(m)
    b = Client(channel=b.channel).register(m)

    m.start()

    try:
        assert pytest.wait_for(a, "ready")
        assert pytest.wait_for(b, "ready")

        a.fire(write(b"foo"))
        assert pytest.wait_for(b, "data", b"foo")

        b.fire(write(b"foo"))
        assert pytest.wait_for(a, "data", b"foo")

        a.fire(close())
        assert pytest.wait_for(a, "disconnected")

        b.fire(close())
        assert pytest.wait_for(b, "disconnected")
    finally:
        m.stop()
开发者ID:spaceone,项目名称:circuits,代码行数:29,代码来源:test_pipe.py

示例4: test_unix

def test_unix(tmpfile, Poller):
    m = Manager() + Poller()

    server = Server() + UNIXServer(tmpfile)
    client = Client() + UNIXClient()

    server.register(m)
    client.register(m)

    m.start()

    try:
        assert pytest.wait_for(server, "ready")
        assert pytest.wait_for(client, "ready")

        client.fire(connect(tmpfile))
        assert pytest.wait_for(client, "connected")
        assert pytest.wait_for(server, "connected")
        assert pytest.wait_for(client, "data", b"Ready")

        client.fire(write(b"foo"))
        assert pytest.wait_for(server, "data", b"foo")

        client.fire(close())
        assert pytest.wait_for(client, "disconnected")
        assert pytest.wait_for(server, "disconnected")

        server.fire(close())
        assert pytest.wait_for(server, "closed")
    finally:
        m.stop()
开发者ID:spaceone,项目名称:circuits,代码行数:31,代码来源:test_unix.py

示例5: test_complex

def test_complex():
    m = Manager()

    a = A()
    b = B()

    a.register(m)
    b.register(a)

    assert a in m
    assert a.root == m
    assert a.parent == m
    assert b in a
    assert b.root == m
    assert b.parent == a

    a.unregister()
    while len(m):
        m.flush()

    assert b.informed
    assert a not in m
    assert a.root == a
    assert a.parent == a
    assert b in a
    assert b.root == a
    assert b.parent == a
开发者ID:AdricEpic,项目名称:circuits,代码行数:27,代码来源:test_component_setup.py

示例6: test_main

def test_main():
    id = "%s:%s" % (os.getpid(), current_thread().getName())

    m = Manager()
    assert repr(m) == "<Manager/ %s (queued=0) [S]>" % id

    app = App()
    app.register(m)
    s = repr(m)
    assert s == "<Manager/ %s (queued=1) [S]>" % id

    m.start()

    pytest.wait_for(m, "_running", True)
    sleep(0.1)

    s = repr(m)
    assert s == "<Manager/ %s (queued=0) [R]>" % id

    m.stop()

    pytest.wait_for(m, "_Manager__thread", None)

    s = repr(m)
    assert s == "<Manager/ %s (queued=0) [S]>" % id
开发者ID:AdricEpic,项目名称:circuits,代码行数:25,代码来源:test_manager_repr.py

示例7: main

def main():
    opts, args = parse_options()

    if ":" in opts.bind:
        address, port = opts.bind.split(":")
        port = int(port)
    else:
        address, port = opts.bind, 8000

    if args:
        x = args[0].split(":")
        if len(x) > 1:
            nodes = [(x[0], int(x[1]))]
        else:
            nodes = [(x[0], 8000)]
    else:
        nodes = []

    manager = Manager()

    debugger = Debugger()
    debugger.IgnoreEvents.extend(["Read", "Write"])
    manager += debugger

    bridge = Bridge(port, address=address, nodes=nodes)
    manager += bridge

    manager.run()
开发者ID:A-K,项目名称:naali,代码行数:28,代码来源:sniffer.py

示例8: test_unix

def test_unix(tmpdir, Poller):
    m = Manager() + Poller()

    sockpath = tmpdir.ensure("test.sock")
    filename = str(sockpath)

    server = Server() + UNIXServer(filename)
    client = Client() + UNIXClient()

    server.register(m)
    client.register(m)

    m.start()

    try:
        assert pytest.wait_for(server, "ready")
        assert pytest.wait_for(client, "ready")

        client.fire(connect(filename))
        assert pytest.wait_for(client, "connected")
        assert pytest.wait_for(server, "connected")
        assert pytest.wait_for(client, "data", b"Ready")

        client.fire(write(b"foo"))
        assert pytest.wait_for(server, "data", b"foo")

        client.fire(close())
        assert pytest.wait_for(client, "disconnected")
        assert pytest.wait_for(server, "disconnected")

        server.fire(close())
        assert pytest.wait_for(server, "closed")
    finally:
        m.stop()
        os.remove(filename)
开发者ID:billtsay,项目名称:win-demo-opcua,代码行数:35,代码来源:test_unix.py

示例9: test_removeHandler

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,代码行数:25,代码来源:test_dynamic_handlers.py

示例10: test_basic

def test_basic(Poller, ipv6):
    m = Manager() + Poller()

    if ipv6:
        udp_server = UDP6Server(("::1", 0))
        udp_client = UDP6Client(("::1", 0), channel="client")
    else:
        udp_server = UDPServer(0)
        udp_client = UDPClient(0, channel="client")
    server = Server() + udp_server
    client = Client() + udp_client

    server.register(m)
    client.register(m)

    m.start()

    try:
        assert pytest.wait_for(server, "ready")
        assert pytest.wait_for(client, "ready")
        wait_host(server)

        client.fire(write((server.host, server.port), b"foo"))
        assert pytest.wait_for(server, "data", b"foo")

        client.fire(close())
        assert pytest.wait_for(client, "closed")

        server.fire(close())
        assert pytest.wait_for(server, "closed")
    finally:
        m.stop()
开发者ID:ke4roh,项目名称:circuits,代码行数:32,代码来源:test_udp.py

示例11: main

def main():
    setprocname(basename(sys.argv[0]))

    config = Config()

    chdir(config["rootdir"])

    logger = setup_logging(config)

    manager = Manager()

    Worker(channel="workers").register(manager)

    if config["debug"]:
        Debugger(
            logger=logger,
            events=config["verbose"],
        ).register(manager)

    Core(config).register(manager)

    try:
        manager.run()
    finally:
        config.save()
开发者ID:carriercomm,项目名称:cgod,代码行数:25,代码来源:main.py

示例12: test_close

def test_close(Poller, ipv6):
    m = Manager() + Poller()
    server = Server() + UDPServer(0)
    server.register(m)
    m.start()

    try:
        assert pytest.wait_for(server, "ready")
        wait_host(server)

        host, port = server.host, server.port

        server.fire(close())
        assert pytest.wait_for(server, "disconnected")

        server.unregister()

        def test(obj, attr):
            return attr not in obj.components
        assert pytest.wait_for(m, server, value=test)

        server = Server() + UDPServer((host, port))
        server.register(m)

        assert pytest.wait_for(server, "ready", timeout=30.0)
    finally:
        m.stop()
开发者ID:ke4roh,项目名称:circuits,代码行数:27,代码来源:test_udp.py

示例13: test_tcp_reconnect

def test_tcp_reconnect(Poller, ipv6):
    # XXX: Apparently this doesn't work on Windows either?
    # XXX: UPDATE: Apparently Broken on Windows + Python 3.2
    # TODO: Need to look into this. Find out why...

    if pytest.PLATFORM == "win32" and pytest.PYVER[:2] >= (3, 2):
        pytest.skip("Broken on Windows on Python 3.2")

    m = Manager() + Poller()

    if ipv6:
        tcp_server = TCP6Server(("::1", 0))
        tcp_client = TCP6Client()
    else:
        tcp_server = TCPServer(0)
        tcp_client = TCPClient()
    server = Server() + tcp_server
    client = Client() + tcp_client

    server.register(m)
    client.register(m)

    m.start()

    try:
        assert pytest.wait_for(client, "ready")
        assert pytest.wait_for(server, "ready")
        wait_host(server)

        # 1st connect
        client.fire(connect(server.host, server.port))
        assert pytest.wait_for(client, "connected")
        assert pytest.wait_for(server, "connected")
        assert pytest.wait_for(client, "data", b"Ready")

        client.fire(write(b"foo"))
        assert pytest.wait_for(server, "data", b"foo")

        # disconnect
        client.fire(close())
        assert pytest.wait_for(client, "disconnected")

        # 2nd reconnect
        client.fire(connect(server.host, server.port))
        assert pytest.wait_for(client, "connected")
        assert pytest.wait_for(server, "connected")
        assert pytest.wait_for(client, "data", b"Ready")

        client.fire(write(b"foo"))
        assert pytest.wait_for(server, "data", b"foo")

        client.fire(close())
        assert pytest.wait_for(client, "disconnected")
        assert pytest.wait_for(server, "disconnected")

        server.fire(close())
        assert pytest.wait_for(server, "closed")
    finally:
        m.stop()
开发者ID:ke4roh,项目名称:circuits,代码行数:59,代码来源:test_tcp.py

示例14: main

def main():
    opts, args = parse_options()

    bind = parse_bind(opts.bind)

    if opts.validate:
        application = (Application() + Root())
        app = validator(application)

        httpd = make_server(bind[0], bind[1], app)
        httpd.serve_forever()

        raise SystemExit(0)

    manager = Manager()

    opts.debug and Debugger().register(manager)

    Poller = select_poller(opts.poller.lower())
    Poller().register(manager)

    if opts.server.lower() == "base":
        BaseServer(bind).register(manager)
        HelloWorld().register(manager)
    else:
        Server(bind).register(manager)
        Root().register(manager)

    docroot = os.getcwd() if not args else args[0]

    Static(docroot=docroot, dirlisting=True).register(manager)

    opts.passwd and Authentication(passwd=opts.passwd).register(manager)

    opts.logging and Logger().register(manager)

    if opts.profile and hotshot:
        profiler = hotshot.Profile(".profile")
        profiler.start()

    if opts.debug:
        print(graph(manager, name="circuits.web"))
        print()
        print(inspect(manager))

    for i in range(opts.jobs):
        manager.start(process=True)

    manager.run()

    if opts.profile and hotshot:
        profiler.stop()
        profiler.close()

        stats = hotshot.stats.load(".profile")
        stats.strip_dirs()
        stats.sort_stats("time", "calls")
        stats.print_stats(20)
开发者ID:ke4roh,项目名称:circuits,代码行数:58,代码来源:main.py

示例15: __init__

        def __init__(self):
            Manager.__init__(self)

            self += GtkDriver()
            self += Debugger()

            self.server = BaseServer(9999)

            self.server += wsgi.Gateway(dummy_app)

            self += self.server
开发者ID:A-K,项目名称:naali,代码行数:11,代码来源:_gtk.py


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