例如,我有一個連接到服務器具有以下客戶:如何在從pb.Root繼承的服務器中檢測丟失的客戶端連接?
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)
所以當連接丟失,客戶端可以自動檢測。
我如何從服務器獲取相同的行爲應該在客戶端下去,例如崩潰?
我現在趕DeadReferenceError,(通過連接的潛在客戶名單迭代),但是這是一個非事件驅動的方式 - 坦率地說爲時已晚。
任何想法表示歡迎。
在此先感謝。
本