[zeromq-dev] Failing to synchronize 0mq sockets

Daniele Varrazzo daniele.varrazzo at gmail.com
Mon Apr 2 23:11:57 CEST 2012


I'm learning some 0mq following the guide and implementing the test
programs in python. I'm using zmq/pyzmq 2.1.9 on Ubuntu.

I'm trying to synchronize subscribers with a publisher using pair
sockets in a multithread script. The script is at
<https://gist.github.com/2286899>. The pattern implemented is
something like:

main thread:
  - create the pub and bind
  - for each worker:
    - create a pair control socket and bind
    - spawn the thread
    - wait for a message on the control socket
  - publish the messages

worker threads:
  - create the sub and connect
  - create a pair control socket and connect
  - send a message on the control socket

I'm experiencing "slow joiner syndrome" here: in a native threads
script, none of the message is received by the workers despite the sub
are connected before an ack message is sent back to the pub thread.
Adding a pause before publishing the message, it works fine. Running
the program in eventlet instead of native threads the slow joining is
even more evident: on my machine one of the threads misses the first
few messages, see the comment at the end of the gist.

Any help in understanding what is going on would be appreciated, thanks.

-- Daniele

More information about the zeromq-dev mailing list