[zeromq-dev] PUSH Socket is queued?

Randall Nortman rnzmq at wonderclown.net
Wed Feb 26 18:48:11 CET 2014


PUSH sockets will return EAGAIN if there are no connected peers, or if
all connected peers have reached their HWM.  HWMs are per peer.  The
HWM only comes into play once there is a connected peer, in which case
messages will be queued up to the HWM and then you will get EAGAIN.

Note that what is meant by "connected peer" differs depending on
whether you are connecting or binding the PUSH socket.  If you bind
it, then there is no connected peer until something else connects to
your bound socket.  If you connect your PUSH socket, then it is
considered connected immediately even before the underlying connection
is established.  So you can start sending to a connected PUSH socket
up to the HWM, even if nobody is listening on the other end, but if
you bind your PUSH socket there is no queuing until something connects
to it.


On Wed, Feb 26, 2014 at 06:04:21PM +0100, Stéphane Wirtel wrote:
> ok, but I thought that you could push your message on an internal small 
> queue and just dispatch them once you have a pull socket.
> 
> is there a pattern for that?
> 
> On 26 Feb 2014, at 18:01, Doron Somech wrote:
> 
> > If you don't have any pull socket connected you can get eagain...
> > On Feb 26, 2014 5:45 PM, "Stéphane Wirtel" <stephane at wirtel.be> 
> > wrote:
> >
> >> With get_hwm() on the socket, the value is 1000.
> >>
> >>
> >> On 26 Feb 2014, at 17:29, Stéphane Wirtel wrote:
> >>
> >>> Hi all,
> >>>
> >>> I wanted to know if there is a queue for the message of a PUSH 
> >>> socket,
> >>> because my send is blocking or in error with the EAGAIN error.
> >>>
> >>> Here is the example:
> >>>
> >>> #!/usr/bin/env python
> >>>
> >>> import zmq
> >>>
> >>> context = zmq.Context()
> >>>
> >>> sender = context.socket(zmq.PUSH)
> >>> sender.bind('tcp://*:5557')
> >>>
> >>> for task in range(100):
> >>> print task
> >>> sender.send_string(u'%d' % task, zmq.DONTWAIT)
> >>>
> >>> sender.close()
> >>> context.terminate()
> >>>
> >>>> (zmq) python push.py
> >>> 0
> >>> Traceback (most recent call last):
> >>> File "push.py", line 12, in <module>
> >>> sender.send_string(u'%d' % task, zmq.DONTWAIT)
> >>> File
> >>>
> >> "/Users/stephane/.virtualenvs/zmq/lib/python2.7/site-packages/zmq/sugar/socket.py",
> >>> line 290, in send_string
> >>> return self.send(u.encode(encoding), flags=flags, copy=copy)
> >>> File "socket.pyx", line 565, in 
> >>> zmq.backend.cython.socket.Socket.send
> >>> (zmq/backend/cython/socket.c:5104)
> >>> File "socket.pyx", line 620, in 
> >>> zmq.backend.cython.socket.Socket.send
> >>> (zmq/backend/cython/socket.c:4972)
> >>> File "socket.pyx", line 156, in 
> >>> zmq.backend.cython.socket._send_frame
> >>> (zmq/backend/cython/socket.c:1842)
> >>> File "checkrc.pxd", line 15, in zmq.backend.cython.checkrc._check_rc
> >>> (zmq/backend/cython/socket.c:5784)
> >>> zmq.error.Again: Resource temporarily unavailable
> >>>
> >>> Do you have an idea?
> >>>
> >>> Thanks
> >>>
> >>> Regards,
> >>>
> >>> Stephane
> >>> _______________________________________________
> >>> zeromq-dev mailing list
> >>> zeromq-dev at lists.zeromq.org
> >>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >> _______________________________________________
> >> zeromq-dev mailing list
> >> zeromq-dev at lists.zeromq.org
> >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >>
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev



More information about the zeromq-dev mailing list