0

ポーラーの代わりにzmqリアクターを使い始める前は、すべてうまく機能していたと言わざるを得ません。

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

そして、1 時間ごとに 1 つの部分だけで構成されるメッセージが届きます。だから私は得た

TypeError: need more than one value to unpack.

編集ここに私の完全なzmqコードがあります。

https://drive.google.com/file/d/0B7jQezPDaLZFQWxBMUdXQkxnS1k/edit?usp=sharing

4

0 に答える 0