[zeromq-dev] How can I handle disconnection?

Martin Sustrik sustrik at fastmq.com
Fri Dec 19 18:22:38 CET 2008


张沈鹏 wrote:
> I saw the "Disconnection handling" in document
> """
> When connection between the nodes breaks, the applications on both
> sides are notified about the fact using a callback function. The name
> of the object (exchange, queue) connection belongs to is passed to the
> function so that if there are multiple connections you can decide
> which one of them actually broke. After handling the disconnection you
> can decide either to ignore the error or cause the application to
> crash.
> """
> But I can't find the disconnection recall function in python api ,
> I also found in python api the receive is always block ,but it can
> easy add  the  no block receive version.

Yes, both things are missing in Python API.

Adding 'block' parameter to receive function should be trivial (tweak 
libpyzmq/pyzmq.cpp to pass the additional argument to the underlying C++ 

As for callback function, this should be possible in Python (deferred 
object?), however, I'm not a Python expert so any opinion on this matter 
would be appreciated.

> But even more I want a receive with timeout :)

This is somehow more complex. Client threads are blocked by most 
efficient locking mechanism we've found i.e. by mutex. However, mutexes 
don't have timeouts. To enable timeouts we would have to change the 
locking mechanism and sacrifice some performance for the functionality. 
It can be made optional of course.

> Finally , how can I do the ACK ?

0MQ does transient messaging. Thus there's no need for ACKs.

Hope this helps.

More information about the zeromq-dev mailing list