Skip to content

Commit

Permalink
Merge pull request #39 from vincentbernat/fix/use-kazooretry
Browse files Browse the repository at this point in the history
Allow a user to configure the number of retries
  • Loading branch information
Olivier Poitrey committed Nov 24, 2013
2 parents 3d2d517 + b947ce5 commit f9f47d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions bin/zkfarmer
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ from zkfarmer.conf import Conf
from zkfarmer.utils import create_filter, dict_filter, ColorizingStreamHandler
from zkfarmer import ZkFarmer, VERSION

from kazoo.client import KazooClient
from kazoo.client import KazooClient, KazooRetry

import logging

Expand All @@ -30,6 +30,9 @@ def main():
parser.add_argument('-V', '--version', action='version', version='%%(prog)s %s' % VERSION)
parser.add_argument('-H', '--host', dest='host', default=os.environ.get('ZKHOST', 'localhost:2181'),
help='list of zookeeper hosts:port sperated by commas')
parser.add_argument('-r', '--retries',
default=5, type=int, metavar="N",
help='retry N times in case of failure')
group = parser.add_mutually_exclusive_group()
group.add_argument('-q', '--quiet', dest='quiet', action='store_true',
help='lower the log level so only warnings and errors are logged')
Expand Down Expand Up @@ -177,7 +180,9 @@ def main():
parser.error(e)
exit(1)

zkconn = KazooClient(args.host, max_retries=5)
zkconn = KazooClient(args.host,
connection_retry=KazooRetry(max_tries=args.retries),
command_retry=KazooRetry(max_tries=args.retries))
zkconn.start()

def sighandler(sig, frame):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
argparse>=1.2.1
watchdog>=0.5.4
PyYAML>=3.10
kazoo>=0.8
kazoo>=1.3.1

0 comments on commit f9f47d7

Please sign in to comment.