MCPcopy Create free account
hub / github.com/apache/cassandra-python-driver / ConstantReconnectionPolicy

Class ConstantReconnectionPolicy

cassandra/policies.py:628–654  ·  view source on GitHub ↗

A :class:`.ReconnectionPolicy` subclass which sleeps for a fixed delay in-between each reconnection attempt.

Source from the content-addressed store, hash-verified

626
627
628class ConstantReconnectionPolicy(ReconnectionPolicy):
629 """
630 A :class:`.ReconnectionPolicy` subclass which sleeps for a fixed delay
631 in-between each reconnection attempt.
632 """
633
634 def __init__(self, delay, max_attempts=64):
635 """
636 `delay` should be a floating point number of seconds to wait in-between
637 each attempt.
638
639 `max_attempts` should be a total number of attempts to be made before
640 giving up, or :const:`None` to continue reconnection attempts forever.
641 The default is 64.
642 """
643 if delay < 0:
644 raise ValueError("delay must not be negative")
645 if max_attempts is not None and max_attempts < 0:
646 raise ValueError("max_attempts must not be negative")
647
648 self.delay = delay
649 self.max_attempts = max_attempts
650
651 def new_schedule(self):
652 if self.max_attempts:
653 return repeat(self.delay, self.max_attempts)
654 return repeat(self.delay)
655
656
657class ExponentialReconnectionPolicy(ReconnectionPolicy):

Calls

no outgoing calls