本文整理汇总了Python中msgpack.Unpacker.next方法的典型用法代码示例。如果您正苦于以下问题:Python Unpacker.next方法的具体用法?Python Unpacker.next怎么用?Python Unpacker.next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msgpack.Unpacker
的用法示例。
在下文中一共展示了Unpacker.next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_api
# 需要导入模块: from msgpack import Unpacker [as 别名]
# 或者: from msgpack.Unpacker import next [as 别名]
def _get_api(self, name, endpoint, port):
locator_pipe = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
locator_pipe.settimeout(4.0)
locator_pipe.connect((endpoint, port))
locator_pipe.send(packb([0, 1, [name]]))
u = Unpacker()
msg = None
while msg is None:
response = locator_pipe.recv(80960)
u.feed(response)
msg = Message.initialize(u.next())
locator_pipe.close()
if msg.id == message.RPC_CHUNK: #PROTOCOL_LIST.index("rpc::chunk"):
return unpackb(msg.data)
if msg.id == message.RPC_ERROR: #PROTOCOL_LIST.index("rpc::error"):
raise Exception(msg.message)
示例2: Unpacker
# 需要导入模块: from msgpack import Unpacker [as 别名]
# 或者: from msgpack.Unpacker import next [as 别名]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. """
if __name__ == '__main__':
from msgpack import Unpacker
from sys import stdin
unpacker = Unpacker(stdin)
# print header:
try:
header = unpacker.next()
print ' '.join(header)
except Exception, e:
print e
# print data:
for msg in unpacker:
try:
print ' '.join(map(str, msg))
except:
pass