Python 每一小时接收一次有错误的zmq消息

Python 每一小时接收一次有错误的zmq消息,python,zeromq,reactor,Python,Zeromq,Reactor,我应该说,在我开始使用zmq反应堆而不是poller之前,一切都很好 class BaseZmqReceiver(BaseZmqNode): __metaclass__ = ABCMeta def __init__(self, host, port, hwm, bind, on_receive_callback): super(BaseZmqReceiver, self).__init__(host=host, port=port, bind=bind, hwm

我应该说,在我开始使用zmq反应堆而不是poller之前,一切都很好

class BaseZmqReceiver(BaseZmqNode):
    __metaclass__ = ABCMeta

    def __init__(self, host, port, hwm, bind, on_receive_callback):
        super(BaseZmqReceiver, self).__init__(host=host, port=port, bind=bind, hwm=hwm)
        self.node.on_message_callback = on_receive_callback
        self.stream = ZMQStream(self.socket)
        self.stream.on_recv(self.on_message_received)
        ZmqLoopRunner().start()

    def on_message_received(self, message):
        return self.node.on_message_callback(message)

    def create_node(self):
        return ReceivingNode(None, None)

class ZmqLoopRunner(Thread):

    def __init__(self):
        super(ZmqLoopRunner, self).__init__()
        self.loop = IOLoop.instance()
        self.daemon = True

    def run(self):
        self.loop.start()

    def stop(self):
        self.loop.stop()


class ZmqSubscriber(BaseZmqReceiver):
    def __init__(self, host, port, on_receive_callback, bind=False, hwm=1000):
        super(ZmqSubscriber, self).__init__(host=host, port=port, hwm=hwm, bind=bind,
                                            on_receive_callback=on_receive_callback)

    def create_socket(self):
        socket = self.context.socket(zmq.SUB)
        socket.setsockopt(zmq.SUBSCRIBE, "")
        return socket
这是我的zmq代码

我基本上只是在回调中接收多部分消息

def on_message(message):
    part1, part2 = message
每过一个小时,我就会收到一条只有一部分的信息。所以我得到了

TypeError: need more than one value to unpack.
编辑这里是我的完整zmq代码


第1部分,第2部分=消息
将尝试解压缩消息。那是一张单子吗?您确定它包含两个部分吗?在zmqloop on_recv中,每条消息都包含多个部分。我的代码大部分时间都是有效的。它在测试中起作用。poller和reactor每小时都在工作,一条消息只有一部分,而不是两部分。我建议将一些数据写入一个文件,然后编辑原始帖子以包含这些数据@Depado已经询问您是否确定消息包含两部分。我们需要什么来运行这个?如果我们想尝试一下,我们需要在本地系统上安装什么?对我来说,错误肯定来自这一行,因为代码中似乎没有任何其他部分可以解包值。看起来您没有收到“消息”,但直接收到了python错误(这是您想要的吗?我不知道zmq),不幸的是,您无法在您的系统上运行它。我只是认为zmq循环有一些明显的错误(对于zmq专家来说)。