Track last_failure in BrokerConnection.close()
This commit is contained in:
@@ -109,13 +109,11 @@ class BrokerConnection(object):
|
|||||||
log.error('Connect attempt to %s returned error %s.'
|
log.error('Connect attempt to %s returned error %s.'
|
||||||
' Disconnecting.', self, ret)
|
' Disconnecting.', self, ret)
|
||||||
self.close()
|
self.close()
|
||||||
self.last_failure = time.time()
|
|
||||||
|
|
||||||
# Connection timedout
|
# Connection timedout
|
||||||
elif time.time() > request_timeout + self.last_attempt:
|
elif time.time() > request_timeout + self.last_attempt:
|
||||||
log.error('Connection attempt to %s timed out', self)
|
log.error('Connection attempt to %s timed out', self)
|
||||||
self.close() # error=TimeoutError ?
|
self.close() # error=TimeoutError ?
|
||||||
self.last_failure = time.time()
|
|
||||||
|
|
||||||
# Needs retry
|
# Needs retry
|
||||||
else:
|
else:
|
||||||
@@ -154,6 +152,7 @@ class BrokerConnection(object):
|
|||||||
self._sock.close()
|
self._sock.close()
|
||||||
self._sock = None
|
self._sock = None
|
||||||
self.state = ConnectionStates.DISCONNECTED
|
self.state = ConnectionStates.DISCONNECTED
|
||||||
|
self.last_failure = time.time()
|
||||||
self._receiving = False
|
self._receiving = False
|
||||||
self._next_payload_bytes = 0
|
self._next_payload_bytes = 0
|
||||||
self._rbuffer.seek(0)
|
self._rbuffer.seek(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user