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


Python cybin.read_val函数代码示例

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


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

示例1: test_byteswap_i16

def test_byteswap_i16():
    i = 128
    b = TCyMemoryBuffer()
    proto.write_val(b, TType.I16, i)
    b.flush()
    v = proto.read_val(b, TType.I16)
    assert v == i
开发者ID:hand515,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py

示例2: test_read_long_data

def test_read_long_data():
    val = 'z' * 97 * 1024

    def serve():
        server_sock = TServerSocket(
            unix_socket="./thriftpy_test.sock")
        server_sock.listen()
        client = server_sock.accept()
        t = TCyBufferedTransport(client)
        proto.write_val(t, TType.STRING, val)
        t.flush()

    p = multiprocessing.Process(target=serve)
    p.start()
    time.sleep(0.1)

    try:
        sock = TSocket(unix_socket="./thriftpy_test.sock")
        b = TCyBufferedTransport(sock)
        b.open()
        assert val == proto.read_val(b, TType.STRING)
        sock.close()
    finally:
        p.terminate()
        try:
            os.remove("./thriftpy_test.sock")
        except IOError:
            pass
开发者ID:GuoJing,项目名称:thriftpy,代码行数:28,代码来源:test_protocol_cybinary.py

示例3: test_skip_string

def test_skip_string():
    b = TCyMemoryBuffer()
    proto.write_val(b, TType.STRING, "hello world")
    proto.write_val(b, TType.I32, 123)
    b.flush()

    proto.skip(b, TType.STRING)
    assert 123 == proto.read_val(b, TType.I32)
开发者ID:GuoJing,项目名称:thriftpy,代码行数:8,代码来源:test_protocol_cybinary.py

示例4: test_skip_double

def test_skip_double():
    b = TCyMemoryBuffer()
    proto.write_val(b, TType.DOUBLE, 0.123425897)
    proto.write_val(b, TType.I32, 123)
    b.flush()

    proto.skip(b, TType.DOUBLE)
    assert 123 == proto.read_val(b, TType.I32)
开发者ID:GuoJing,项目名称:thriftpy,代码行数:8,代码来源:test_protocol_cybinary.py

示例5: test_skip_bool

def test_skip_bool():
    b = TCyMemoryBuffer()
    proto.write_val(b, TType.BOOL, 1)
    proto.write_val(b, TType.I32, 123)
    b.flush()

    proto.skip(b, TType.BOOL)
    assert 123 == proto.read_val(b, TType.I32)
开发者ID:GuoJing,项目名称:thriftpy,代码行数:8,代码来源:test_protocol_cybinary.py

示例6: test_skip_map

def test_skip_map():
    b = TCyMemoryBuffer()
    proto.write_val(b, TType.MAP, {"hello": 0.3456}, spec=(TType.STRING, TType.DOUBLE))
    proto.write_val(b, TType.I32, 123)
    b.flush()

    proto.skip(b, TType.MAP)
    assert 123 == proto.read_val(b, TType.I32)
开发者ID:hand515,项目名称:thriftpy,代码行数:8,代码来源:test_protocol_cybinary.py

示例7: test_skip_list

def test_skip_list():
    b = TCyMemoryBuffer()
    proto.write_val(b, TType.LIST, [5, 6, 7, 8, 9], spec=TType.I32)
    proto.write_val(b, TType.I32, 123)
    b.flush()

    proto.skip(b, TType.LIST)
    assert 123 == proto.read_val(b, TType.I32)
开发者ID:GuoJing,项目名称:thriftpy,代码行数:8,代码来源:test_protocol_cybinary.py

示例8: test_skip_struct

def test_skip_struct():
    b = TCyMemoryBuffer()
    p = proto.TCyBinaryProtocol(b)
    item = TItem(id=123, phones=["123456", "abcdef"])
    p.write_struct(item)
    p.write_message_end()

    proto.write_val(b, TType.I32, 123)
    b.flush()

    proto.skip(b, TType.STRUCT)
    assert 123 == proto.read_val(b, TType.I32)
开发者ID:GuoJing,项目名称:thriftpy,代码行数:12,代码来源:test_protocol_cybinary.py

示例9: test_read_long_data

def test_read_long_data():
    val = 'z' * 97 * 1024

    def serve():
        server_sock = TServerSocket(host="127.0.0.1", port=9090)
        server_sock.listen()
        client = server_sock.accept()
        t = TCyBufferedTransport(client)
        proto.write_val(t, TType.STRING, val)
        t.flush()

    p = multiprocessing.Process(target=serve)
    p.start()
    time.sleep(0.1)

    try:
        sock = TSocket(host='127.0.0.1', port=9090)
        b = TCyBufferedTransport(sock)
        b.open()
        assert val == proto.read_val(b, TType.STRING)
    finally:
        p.terminate()
开发者ID:gladhorn,项目名称:thriftpy,代码行数:22,代码来源:test_protocol_cybinary.py

示例10: test_read_i8

def test_read_i8():
    b = TMemoryBuffer(b'\x7b')
    b = TCyBufferedTransport(b)
    val = proto.read_val(b, TType.I08)

    assert 123 == val
开发者ID:lepture,项目名称:thriftpy,代码行数:6,代码来源:test_protocol_cybinary.py

示例11: test_read_i16

def test_read_i16():
    b = TMemoryBuffer(b"09")
    b = TCyBufferedTransport(b)
    val = proto.read_val(b, TType.I16)

    assert 12345 == val
开发者ID:lepture,项目名称:thriftpy,代码行数:6,代码来源:test_protocol_cybinary.py

示例12: test_read_string

def test_read_string():
    b = TMemoryBuffer(b"\x00\x00\x00\x0c"
                      b"\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xb8\x96\xe7\x95\x8c")
    b = TCyBufferedTransport(b)
    assert u("你好世界") == proto.read_val(b, TType.STRING)
开发者ID:lepture,项目名称:thriftpy,代码行数:5,代码来源:test_protocol_cybinary.py

示例13: test_read_bool

def test_read_bool():
    b = TMemoryBuffer(b'\x01')
    b = TCyBufferedTransport(b)
    val = proto.read_val(b, TType.BOOL)

    assert True is val
开发者ID:lepture,项目名称:thriftpy,代码行数:6,代码来源:test_protocol_cybinary.py

示例14: test_read_i32

def test_read_i32():
    b = TCyMemoryBuffer(b"I\x96\x02\xd2")
    assert 1234567890 == proto.read_val(b, TType.I32)
开发者ID:GuoJing,项目名称:thriftpy,代码行数:3,代码来源:test_protocol_cybinary.py

示例15: test_read_double

def test_read_double():
    b = TMemoryBuffer(b"A\xd2e\x80\xb4\x87\xe6\xb7")
    b = TCyBufferedTransport(b)
    assert 1234567890.1234567890 == proto.read_val(b, TType.DOUBLE)
开发者ID:lepture,项目名称:thriftpy,代码行数:4,代码来源:test_protocol_cybinary.py


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