From 7aa8f3037538b786814ec870ce8282e7f3c534db Mon Sep 17 00:00:00 2001 From: Tom Lin Date: Mon, 25 May 2015 16:11:35 +0800 Subject: [PATCH] Check if max_attempts is None --- cassandra/policies.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cassandra/policies.py b/cassandra/policies.py index ce879abb..d4d8914c 100644 --- a/cassandra/policies.py +++ b/cassandra/policies.py @@ -509,14 +509,16 @@ class ConstantReconnectionPolicy(ReconnectionPolicy): """ if delay < 0: raise ValueError("delay must not be negative") - if max_attempts < 0: + if max_attempts is not None and max_attempts < 0: raise ValueError("max_attempts must not be negative") self.delay = delay self.max_attempts = max_attempts def new_schedule(self): - return repeat(self.delay, self.max_attempts) + if self.max_attempts: + return repeat(self.delay, self.max_attempts) + return repeat(self.delay) class ExponentialReconnectionPolicy(ReconnectionPolicy):