On Aug 15, 2012, at 6:50 AM, andrea crotti wrote:

> Very good makes sense, but then why this also hangs forever??
> 
> if __name__ == '__main__':
>    p1 = Process(target=start_send)
>    p2 = Process(target=start_receive)
>    p3 = Process(target=start_receive)
>    p2.start()
>    p3.start()
>    sleep(0.1)
>    p1.start()
> 
> I mean now the two receivers are started before the sender does, but
> the first receiver gets both messages, is that normal?
> 
> In a normal situation probably it won't matter because the first
> worker should be busy doing something so the other could get the
> message, but just to understand..

It hangs for the same reason that the first example hangs. The "connect" action 
of the two receivers retries asynchronously until they succeed. When either of 
the receive processes connects, it gets *both* messages. The second receive 
process hasn't connected yet.

You need to change your timing so that the sender and receiver processes are 
*all* up and connected before you try sending any data. You'll need to separate 
out the bind/connect logic, do a short sleep after that (or use a mutex & 
condition variable to signal completion), and then send your data.

cr


_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to