[zeromq-dev] zmqstream with req socket only sends the first message

MinRK benjaminrk at gmail.com
Mon Feb 2 23:00:45 CET 2015


Calling send on the zmqstream from another thread doesn’t properly tell the
IOLoop thread that there’s an event to process. This could call small
delays if the IOLoop is already processing lots of events, but it can cause
the message to never send if the zmq socket is the only one it’s handling.

You want your ZmqREQConnection.send to hand off the stream.send to the
IOLoop’s thread via IOLoop.add_callback:

def send(self, *args, **kwargs):
    print("Sending message to backend: (%s, %s)" % (args, kwargs))
    self._ioloop.add_callback(lambda : self._stream.send(*args, **kwargs))

-MinRK

On Mon, Feb 2, 2015 at 12:58 PM, drebs drebs at riseup.net
<http://mailto:drebs@riseup.net> wrote:
>

Hello, zmq community.

I’m trying to use a pyzmq’s zmqstream with a REQ socket to talk to a txzmq
REP
socket, but only the first message is ever sent and received back.

REQ pyzmq endpoint code: http://paste.debian.net/143615/
REP txzmq endpoint code: http://paste.debian.net/143617/

I would expect that all the messages would be sent. Am I missing something
here?

If I let some requests accumulate, and then start the server, all the
accumulated requests are replied, but the new ones are not sent.

If I replace the REQ endpoint by a pure pyzmq version with no zmqstream or
ioloop, it works fine (http://paste.debian.net/143619/).

Anyone can give some light on this?

Thanks a lot!
drebs.

—
------------------------------

zeromq-dev mailing list
zeromq-dev at lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150202/8016b323/attachment.htm>


More information about the zeromq-dev mailing list