[zeromq-dev] HWM/Swap refire question

Oliver Smith oliver at kfs.org
Wed Jun 8 21:51:03 CEST 2011

What triggers the refire / draining of the HWM Swap? Is there a way to 
poke it?

If I create a simple client that sends console input to a simple server, 
and ctrl-c the server for a while, when it reconnects, it immediately 
gets the first few messages from the HWM (although sometimes it gets one 

But the SWAP messages only seem to get transported as additional 
messages are pushed into the queue.

Is there any way to modify this behavior, as I can see a situation where 
a stall occurs;

            +--------------          +------------+
  --sockA-->| Processor A |--sockB-->| ProcessorB |->-[ destination ]
      ^     +-------------+          +------+-----+
      |                                     v

Data that needs reprocessing is reinjected to ProcA via SockC, otherwise 
it is forwarded on to destination.

. External input via sockA has ended (e.g. end of file),
. ProcessorB has completed it's last block and queued it onto sockC,
. sockC was interrupted and HWM + Swap were used to buffer remaining 
reprocess data,
. None of the data queued in the HWM needs reprocessing and so is 
forwarded on to destination,
. Remaining messages in swap are never pushed to ProcA

Here's a short video demonstrating exactly what I mean... The swap 
buffered messages remain in the queue until they are pushed into HWM by 
sending a new message on the socket.


Server code:

import zmq
c = zmq.Context(1)
s = c.socket(zmq.PULL)
s.setsockopt(zmq.LINGER, 0)
s.setsockopt(zmq.IDENTITY, "test")
while True:
   print("Got %s" % s.recv())

Client code:

import zmq
c = zmq.Context(1)
s = c.socket(zmq.PUSH)
s.setsockopt(zmq.LINGER, 0)
s.setsockopt(zmq.HWM, 4)
s.setsockopt(zmq.SWAP, 4096)
while True:

More information about the zeromq-dev mailing list