本文整理汇总了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()