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


Python zmqpy.Context类代码示例

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


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

示例1: test_socket_connected_recv

    def test_socket_connected_recv(self):
        from zmqpy import Context, PAIR
        from zmqpy._cffi import zmq_version

        c = Context()
        sender = c.socket(PAIR)
        receiver = c.socket(PAIR)

        bind = receiver.bind('tcp://*:3333')
        connect = sender.connect('tcp://127.0.0.1:3333')

        assert bind == 0
        assert connect == 0

        ret = sender.send("zmqpy test message")
        if zmq_version == 2:
            assert ret == 0
        else:
            assert ret == 18

        assert sender.last_errno == None

        import time
        time.sleep(0.2)
        message = receiver.recv()

        assert sender.last_errno == None
        assert message == "zmqpy test message"

        sender.close()
        receiver.close()
开发者ID:pfw,项目名称:zmqpy,代码行数:31,代码来源:test_zmqpy.py

示例2: test_socket_connected_recv

    def test_socket_connected_recv(self):
        from zmqpy import Context, PAIR

        c = Context()
        sender = c.socket(PAIR)
        receiver = c.socket(PAIR)

        bind = receiver.bind("tcp://*:3333")
        connect = sender.connect("tcp://127.0.0.1:3333")

        assert bind == 0
        assert connect == 0

        ret = sender.send("zmqpy test message")

        assert ret == 0
        assert sender.last_errno == None

        import time

        time.sleep(0.2)
        message = receiver.recv()

        assert sender.last_errno == None
        assert message == "zmqpy test message"

        sender.close()
        receiver.close()
开发者ID:eallik,项目名称:zmqpy,代码行数:28,代码来源:test_zmqpy.py

示例3: test_socket_setsockopt_int

    def test_socket_setsockopt_int(self):
        from zmqpy import Context, PAIR, ZMQ_LINGER
        c = Context()
        sender = c.socket(PAIR)

        rc = sender.setsockopt(ZMQ_LINGER, 10)
        assert rc == 0
        sender.close()
开发者ID:pfw,项目名称:zmqpy,代码行数:8,代码来源:test_zmqpy.py

示例4: test_socket_setsockopt_int64

    def test_socket_setsockopt_int64(self):
        from zmqpy import Context, PAIR, ZMQ_RATE
        c = Context()
        sender = c.socket(PAIR)

        rc = sender.setsockopt(ZMQ_RATE, 200)
        assert rc == 0
        sender.close()
开发者ID:pfw,项目名称:zmqpy,代码行数:8,代码来源:test_zmqpy.py

示例5: test_socket_setsockopt_binary

    def test_socket_setsockopt_binary(self):
        from zmqpy import Context, PAIR, ZMQ_IDENTITY
        c = Context()
        sender = c.socket(PAIR)

        rc = sender.setsockopt(ZMQ_IDENTITY, "id")
        assert rc == 0
        sender.close()
开发者ID:pfw,项目名称:zmqpy,代码行数:8,代码来源:test_zmqpy.py

示例6: test_context_term

    def test_context_term(self):
        from zmqpy import Context

        c = Context()

        c.term()

        assert c.closed
        assert c.zmq_ctx == None
开发者ID:pfw,项目名称:zmqpy,代码行数:9,代码来源:test_zmqpy.py

示例7: test_socket_bind

    def test_socket_bind(self):
        from zmqpy import Context, PAIR
        c = Context()
        socket = c.socket(PAIR)

        bind = socket.bind('tcp://*:3333')
        assert bind == 0

        socket.close()
开发者ID:pfw,项目名称:zmqpy,代码行数:9,代码来源:test_zmqpy.py

示例8: test_context_socket

    def test_context_socket(self):
        from zmqpy import Context, PAIR

        c = Context()
        socket = c.socket(PAIR)

        assert socket
        assert c.n_sockets == 1
        assert len(c._sockets) == 1
        assert not c.closed
开发者ID:pfw,项目名称:zmqpy,代码行数:10,代码来源:test_zmqpy.py

示例9: test_socket_disconnected_send

    def test_socket_disconnected_send(self):
        from zmqpy import Context, PAIR, NOBLOCK
        c = Context()
        socket = c.socket(PAIR)

        ret = socket.send("zmqpy test message", NOBLOCK)

        assert ret == -1
        assert socket.last_errno > 0

        socket.close()
开发者ID:pfw,项目名称:zmqpy,代码行数:11,代码来源:test_zmqpy.py

示例10: test_socket_getsockopt_int

    def test_socket_getsockopt_int(self):
        from zmqpy import Context, PAIR, LINGER
        c = Context()
        sender = c.socket(PAIR)

        rc = sender.setsockopt(LINGER, 10)
        assert rc == 0

        opt_value = sender.getsockopt(LINGER)
        assert opt_value != -1
        assert opt_value == 10
        sender.close()
开发者ID:antocuni,项目名称:zmqpy,代码行数:12,代码来源:test_zmqpy.py

示例11: test_socket_getsockopt_binary

    def test_socket_getsockopt_binary(self):
        from zmqpy import Context, PAIR, ZMQ_IDENTITY
        c = Context()
        sender = c.socket(PAIR)

        rc = sender.setsockopt(ZMQ_IDENTITY, "id")
        assert rc == 0

        opt_value = sender.getsockopt(ZMQ_IDENTITY, length=2)
        assert opt_value != -1
        assert opt_value == "id"
        sender.close()
开发者ID:pfw,项目名称:zmqpy,代码行数:12,代码来源:test_zmqpy.py

示例12: test_socket_getsockopt_int64

    def test_socket_getsockopt_int64(self):
        from zmqpy import Context, PAIR, RATE
        c = Context()
        sender = c.socket(PAIR)

        rc = sender.setsockopt(RATE, 200)
        assert rc == 0

        opt_value = sender.getsockopt(RATE)
        assert opt_value != -1
        assert opt_value == 200
        sender.close()
开发者ID:antocuni,项目名称:zmqpy,代码行数:12,代码来源:test_zmqpy.py

示例13: test_socket_getsockopt_uint64

    def test_socket_getsockopt_uint64(self):
        from zmqpy import Context, PAIR, ZMQ_HWM

        c = Context()
        sender = c.socket(PAIR)

        rc = sender.setsockopt(ZMQ_HWM, 10)
        assert rc == 0

        opt_value = sender.getsockopt(ZMQ_HWM)
        assert opt_value != -1
        assert opt_value == 10
        sender.close()
开发者ID:eallik,项目名称:zmqpy,代码行数:13,代码来源:test_zmqpy.py

示例14: test_socket_connect

    def test_socket_connect(self):
        from zmqpy import Context, PAIR
        c = Context()
        sender = c.socket(PAIR)
        receiver = c.socket(PAIR)

        bind = receiver.bind('tcp://*:3333')
        assert bind == 0

        connect = sender.connect('tcp://127.0.0.1:3333')
        assert connect == 0

        sender.close()
        receiver.close()
开发者ID:pfw,项目名称:zmqpy,代码行数:14,代码来源:test_zmqpy.py

示例15: test_socket_setsockopt_uint64

    def test_socket_setsockopt_uint64(self):
        from zmqpy._cffi import zmq_version
        if zmq_version == 2:
            from zmqpy import Context, PAIR, ZMQ_HWM
        else:
            from zmqpy import Context, PAIR, ZMQ_RCVHWM
            ZMQ_HWM = ZMQ_RCVHWM

        c = Context()
        sender = c.socket(PAIR)

        rc = sender.setsockopt(ZMQ_HWM, 10)
        assert rc == 0
        sender.close()
开发者ID:pfw,项目名称:zmqpy,代码行数:14,代码来源:test_zmqpy.py


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