On Wednesday 16 February 2005 04:56, Dave Cook wrote:
I'm rendering the results of a remote method call:
def data_tableList(self, ctx, data): ... d = self.pbClientFactory.login(creds) d.addCallback(lambda object: object.callRemote("foo")) return d but seems like a hack. Also, ideally, I'd like to attempt a reconnection to the PB server at this point if it's not running. What's the best way to do that?
Maybe it's because the connection succeeds, but *after* that, your server
crashes or something else, so it's not catched by this code. You should use
the notifyOnDisconnect() method for this. Here's a snippet of code I use
regularly to do this:
[...]
def connect(self):
factory = pb.PBClientFactory()
reactor.connectTCP(distantServer, distantPort, factory)
def1 = factory.login(credentials.UsernamePassword(user, password),
client=self)
def1.addCallbacks(callback=self.connected, errback=self.noLogin)
def noLogin(self, reason):
reactor.callLater(5, self.connect) # retry after 5 seconds
def connected(self, perspective):
self.presence = perspective
perspective.notifyOnDisconnect(self.server_disconnected)
def server_disconnected(self, ref):
reactor.callLater(5, self.connect) # retry after 5 seconds
[...]
Luc
--
Luc Stepniewski