Handle exhausted reconnection schedule correctly

This commit is contained in:
Tyler Hobbs
2014-05-06 13:56:17 -05:00
parent c37f770585
commit e6d56ba000
2 changed files with 14 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ Bug Fixes
* Fix duplicate node-up handling, which could result in multiple reconnectors
being started as well as the executor threads becoming deadlocked, preventing
future node up or node down handling from being executed.
* Handle exhausted ReconnectionPolicy schedule correctly
Other
-----

View File

@@ -167,9 +167,20 @@ class _ReconnectionHandler(object):
try:
conn = self.try_reconnect()
except Exception as exc:
next_delay = self.schedule.next()
try:
next_delay = self.schedule.next()
except StopIteration:
# the schedule has been exhausted
next_delay = None
# call on_exception for logging purposes even if next_delay is None
if self.on_exception(exc, next_delay):
self.scheduler.schedule(next_delay, self.run)
if next_delay is None:
log.warn(
"Will not continue to retry reconnection attempts "
"due to an exhausted retry schedule")
else:
self.scheduler.schedule(next_delay, self.run)
else:
if not self._cancelled:
self.on_reconnection(conn)