【发布时间】:2010-02-02 14:25:19
【问题描述】:
例如,我有一个客户端通过以下方式连接到服务器:
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,(通过遍历可能连接的客户端列表)但这是一种非事件驱动的方式 - 坦率地说为时已晚。
欢迎任何想法。
提前致谢。
本
【问题讨论】: