Hi,
I may found a bug in pyzmq or zeromq. When a request is sent on an host which is not connected
context.term() method will hang. I think the socket close method should discard every operations pending.
I don't know if it is an issue from zeromq or pyzmq, anyway here is the code to reproduce the bug.
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import zmq
>>> ctx = zmq.Context()
>>> sock = ctx.socket(zmq.REQ)
>>> sock.connect("tcp://localhost:5000") # no zeromq socket listen here
>>> sock.send("lol")
>>>
>>> sock.close()
>>> ctx.term() # this hangs
I use 2.1.4 version of zeromq and pyzmq.
Not a bug, see documentation of ZMQ_LINGER sockopt for explanation: http://api.zeromq.org/2-1-1:zmq-setsockopt
The default value is -1, which means wait until all messages have been sent before allowing termination. Set to 0 to discard unsent messages immediately, and any positive integer will be the number of milliseconds to keep trying to send before discard.
Calling:
sock.setsockopt(zmq.LINGER, n)
with any non-negative integer n
will prevent ctx.term()
from hanging indefinitely.
Ho, thank you !
Sorry for the noise.
I know this is a very old issue but I am using
In [18]: zmq.__version__
Out[18]: '2.0.10.1'
is there a way to set linger? for this version of pyzmq? Thanks
libzmq 2.0 does not have a LINGER option.
OK thanks. Guess it is time to upgrade. Thanks for your help
Most helpful comment
Not a bug, see documentation of ZMQ_LINGER sockopt for explanation: http://api.zeromq.org/2-1-1:zmq-setsockopt
The default value is -1, which means wait until all messages have been sent before allowing termination. Set to 0 to discard unsent messages immediately, and any positive integer will be the number of milliseconds to keep trying to send before discard.
Calling:
sock.setsockopt(zmq.LINGER, n)
with any non-negative integern
will preventctx.term()
from hanging indefinitely.