[zeromq-dev] multiprocessing + testing with pyzmq
Ian Barber
ian.barber at gmail.com
Mon Oct 3 10:56:11 CEST 2011
On Mon, Oct 3, 2011 at 8:16 AM, Sean Ochoa <sean.m.ochoa at gmail.com> wrote:
> I tried using a child req > parent reply pattern to force the children to
> wait to exit until all the messages are processed, but that might not be the
> best solution. I've attached a copy of my test script that doesn't work yet.
>
Push/Pull is probably the right pattern here. The req rep is
convenient if you want acknowledgment, but I think in your case it's
just the exiting that is the problem - you could handle that with the
ZMQ_LINGER socket option, when you can control how long the child will
wait to deliver it's messages when terminating. Your loop is probably
doing a bit more work than you want as well - look at the zmq.Poller()
- you can add all your sockets to that (both update and exit), and
wait until one of them sends a message on either type of socket, and
handle appropriately, which hopefully will make your parent process
responsive enough most of this issue goes away anyway.
Ian
More information about the zeromq-dev
mailing list