multiprocessing managers and socket connection.

Terry terry.yinzhe at gmail.com
Mon Aug 31 22:41:26 EDT 2009


On Aug 26, 7:25 pm, Chris <chris... at gmail.com> wrote:
> On Aug 25, 9:11 pm, Terry <terry.yin... at gmail.com> wrote:
>
>
>
>
>
> > On Aug 25, 10:14 pm, Chris <chris... at gmail.com> 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 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?
>
> > I think you need to retry repeatedly until successfully connected.
>
> > br, Terry
>
> I'm having issue after once connected. If the server goes down during
> a long-running connection. I would want to be notified so I could try
> to reconnect. I'm doing more experimenting now and will try to post an
> example.

Hi Chris,

Are you sure that the proxy object keeps a permanent connection to the
server?

br, Terry



More information about the Python-list mailing list