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


Python Unpacker.next方法代码示例

本文整理汇总了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)
开发者ID:mou,项目名称:cocaine-framework-python,代码行数:19,代码来源:services.py

示例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

开发者ID:Aerobota,项目名称:PenguPilot,代码行数:31,代码来源:msgpack_to_txt.py


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