For example, I have a client that connects to the 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)
So the client can automatically detect when a connection is lost.
How do I get the same behaviour from the server should a client go down, for example crashing?
I currently catch a DeadReferenceError, (by iterating through a list of potentially connected clients) but that is a non-event driven way - and frankly too late.
Any ideas welcome.
Thanks in advance.
Ben