multiprocessing managers and socket connection.

Terry terry.yinzhe at
Wed Aug 26 03:11:53 CEST 2009

On Aug 25, 10:14 pm, Chris <chris... at> wrote:
> 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
> 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?

I think you need to retry repeatedly until successfully connected.

br, Terry

More information about the Python-list mailing list