Skip to content

Commit 137b5d1

Browse files
committed
Fix examples in recipes
Fix the recipe examples, so they actually work by connecting to ZooKeeper. Without start() they just hang and can't be killed.
1 parent 9d43660 commit 137b5d1

5 files changed

Lines changed: 5 additions & 0 deletions

File tree

kazoo/recipe/counter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Counter(object):
2929
.. code-block:: python
3030
3131
zk = KazooClient()
32+
zk.start()
3233
counter = zk.Counter("/int")
3334
counter += 2
3435
counter -= 1

kazoo/recipe/election.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Election(object):
1313
Example usage with a :class:`~kazoo.client.KazooClient` instance::
1414
1515
zk = KazooClient()
16+
zk.start()
1617
election = zk.Election("/electionpath", "my-identifier")
1718
1819
# blocks until the election is won, then calls

kazoo/recipe/lease.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class NonBlockingLease(object):
2929
Example usage: with a :class:`~kazoo.client.KazooClient` instance::
3030
3131
zk = KazooClient()
32+
zk.start()
3233
# Hold lease over an hour in order to keep job on same machine, with failover if it dies.
3334
lease = zk.NonBlockingLease("/db_leases/hourly_cleanup", datetime.timedelta(minutes = 70),
3435
identifier = "DB hourly cleanup on " + socket.gethostname())

kazoo/recipe/lock.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class Lock(object):
6060
.. code-block:: python
6161
6262
zk = KazooClient()
63+
zk.start()
6364
lock = zk.Lock("/lockpath", "my-identifier")
6465
with lock: # blocks waiting for lock acquisition
6566
# do something with the lock

kazoo/recipe/partitioner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class SetPartitioner(object):
8080
8181
from kazoo.client import KazooClient
8282
client = KazooClient()
83+
client.start()
8384
8485
qp = client.SetPartitioner(
8586
path='/work_queues', set=('queue-1', 'queue-2', 'queue-3'))

0 commit comments

Comments
 (0)