For example, I have a client that connects to a server with the following:
class MyClientFactory(pb.PBClientFactory, ReconnectingClientFactory): def __init__(self): pb.PBClientFactory.__init__(self) self.ipaddress = None def clientConnectionMade(self, broker): log.msg('Started to connect.') pb.PBClientFactory.clientConnectionMade(self, broker) def buildProtocol(self, addr): log.msg('Connected to %s' % addr) return pb.PBClientFactory.buildProtocol(self, addr) def clientConnectionLost(self, connector, reason): log.msg('Lost connection. Reason:', reason) ReconnectingClientFactory.clientConnectionLost(self, connector, reason) def clientConnectionFailed(self, connector, reason): log.msg('Connection failed. Reason:', reason) ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
Thus, the client can automatically detect when the connection is lost.
How can I get the same behavior from the server if the client goes down, for example, a failure?
Currently, I will catch a DeadReferenceError (by repeating a list of potentially related clients), but this is a non-event path and, frankly, it's too late.
Any ideas are welcome.
Thanks in advance.
Ben
source share