multiprocessing managers and socket connection.

Chris chris0wj at gmail.com
Tue Aug 25 10:14:12 EDT 2009


I've been using multiprocessing managers and I really like the
functionality.

I have a question about reconnecting to a manager. I have a situation
where I start on one machine (A) a manager that is listening and then
on another machine (B) connects to that manager and uses its proxy
object to call functions on the manager's computer; this all works as
expected. But, if the manager from A shuts down, B's application won't
notice because in the MP code it ignores socket error
errno.ECONNREFUSED. If A becomes available again or is restarted, B
doesn't automatically reconnect either and continue its operation.
It's function is basically stopped.

Here is the code from connection.py:
while 1:
        try:
            s.connect(address)
        except socket.error, e:
            if e.args[0] != errno.ECONNREFUSED: # connection refused
                debug('failed to connect to address %s', address)
                raise
            time.sleep(0.01)
        else:
            break

How can I have B automatically reconnect to A and continue its work
once A is available again?



More information about the Python-list mailing list