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


Python Unpacker.__next__方法代码示例

本文整理汇总了Python中msgpack.Unpacker.__next__方法的典型用法代码示例。如果您正苦于以下问题:Python Unpacker.__next__方法的具体用法?Python Unpacker.__next__怎么用?Python Unpacker.__next__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在msgpack.Unpacker的用法示例。


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

示例1: delta_status

# 需要导入模块: from msgpack import Unpacker [as 别名]
# 或者: from msgpack.Unpacker import __next__ [as 别名]
    def delta_status(self):
        """
        Loop thread function that collects and updates delta's status and command's output
        """
        recv_until = -1
        unpacker = Unpacker()
        while True:
            if self.killthread:
                self.udp_sock.close()
                return
            else:
                buf = self.udp_sock.recv(4096)
                payload = unpackb(buf)
                # print(payload)
                if payload[0] == 0:
                    if payload[2] - 1 - payload[3] > recv_until:  # finish_index = next_index - 1 - command_in_queue
                        for i in range(recv_until + 1, payload[2] - 1 - payload[3] + 1):
                            if self.command_output[i]:
                                ret = self.control_sock.recv(4096)
                                unpacker.feed(ret)
                                ret = unpacker.__next__()
                                self.lock.acquire()
                                self.command_output[i] = self.command_output[i](ret)
                                self.lock.release()
                            elif self.command_output[i] is False:
                                self.lock.acquire()
                                self.command_output[i] = None
                                self.lock.release()
                            else:
                                print('         --->>>no way!!', self.command_output[i], self.command_output)

                        recv_until = payload[2] - 1 - payload[3]

                    self.atomic_status((payload[2], payload[3]))
                elif payload[0] == 1:
                    # print(payload)
                    self.lock.acquire()
                    self.head_status = payload[1:]
                    self.head_error = payload[3]
                    if self.head_error > 0:
                        if self.headerror_callback:
                            self.headerror_callback(self.head_error)
                        self.send_command([CMD_CLHE])
                    self.lock.release()
                elif payload[0] == 2:
                    self.lock.acquire()
                    self.serial_status = payload[1:]
                    self.lock.release()
开发者ID:flux3dp,项目名称:fluxclient,代码行数:50,代码来源:delta.py


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