Check if max_attempts is None

This commit is contained in:
Tom Lin
2015-05-25 16:11:35 +08:00
parent ff1d75a506
commit 7aa8f30375

View File

@@ -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):
if self.max_attempts:
return repeat(self.delay, self.max_attempts)
return repeat(self.delay)
class ExponentialReconnectionPolicy(ReconnectionPolicy):