Bugfix sleep func missing in Kazoo client
This patch is adding the sleep function needed in the connection_retry and command_retry parameters. The KazooClient is trying to compare them with the ones included in the handler at instantiation.
import logging
+import time
-from kazoo.client import KazooClient, KazooState
+from kazoo.client import KazooClient, KazooState, KazooRetry
from kazoo.exceptions import NoNodeError, NodeExistsError
from kazoo.handlers.threading import SequentialThreadingHandler
from patroni.dcs import AbstractDCS, ClusterConfig, Cluster, Failover, Leader, Member, SyncState
@@ -51,8 +52,9 @@ class ZooKeeper(AbstractDCS):
hosts = ','.join(hosts)
self._client = KazooClient(hosts, handler=PatroniSequentialThreadingHandler(config['retry_timeout']),
- timeout=config['ttl'], connection_retry={'max_delay': 1, 'max_tries': -1},
- command_retry={'deadline': config['retry_timeout'], 'max_delay': 1, 'max_tries': -1})
+ timeout=config['ttl'], connection_retry=KazooRetry(max_delay=1, max_tries=-1,
+ sleep_func=time.sleep), command_retry=KazooRetry(deadline=config['retry_timeout'],
+ max_delay=1, max_tries=-1, sleep_func=time.sleep))
self._client.add_listener(self.session_listener)
self._my_member_data = None
