def clientConnectionLost(self, connector, reason):
"""Handle notification from the lower layers of connection loss.
If we are shutting down, and twisted sends us the expected type of
error, eat the error. Otherwise, log it and pass it along.
Also, schedule notification of our subscribers at the next pass
through the reactor.
"""
if self.dDown and reason.check(ConnectionDone):
# We initiated the close, this is an expected close/lost
log.debug('%r: Connection Closed:%r:%r', self, connector, reason)
notifyReason = None # Not a failure
else:
log.debug('%r: clientConnectionLost:%r:%r', self, connector,
reason)
notifyReason = reason
# Reset our proto so we don't try to send to a down connection
self.proto = None
# Schedule notification of subscribers
self._get_clock().callLater(0, self._notify, False, notifyReason)
# Call our superclass's method to handle reconnecting
ReconnectingClientFactory.clientConnectionLost(
self, connector, reason)
评论列表
文章目录