diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8a5a0fd1..a19653b5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 ----- diff --git a/cassandra/pool.py b/cassandra/pool.py index 7fd8e355..755fac26 100644 --- a/cassandra/pool.py +++ b/cassandra/pool.py @@ -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)