Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added recursive_delete method to KazooClient

  • Loading branch information...
commit b9fbe49c97ba31231aa647391512722651cc515c 1 parent 39e310b
@labisso labisso authored
Showing with 16 additions and 4 deletions.
  1. +13 −1 kazoo/client.py
  2. +3 −3 kazoo/zkclient.py
View
14 kazoo/client.py
@@ -1,7 +1,7 @@
import logging
from kazoo.zkclient import ZooKeeperClient, WatchedEvent, KeeperState,\
- EventType, NodeExistsException
+ EventType, NodeExistsException, NoNodeException
from kazoo.retry import KazooRetry
log = logging.getLogger(__name__)
@@ -211,6 +211,18 @@ def ensure_path(self, path):
# someone else created the node. how sweet!
pass
+ def recursive_delete(self, path):
+ """Recursively delete a ZNode and all of its children
+ """
+ children = self.get_children(path)
+ if children:
+ for child in children:
+ self.recursive_delete(path + "/" + child)
+ try:
+ self.delete(path)
+ except NoNodeException:
+ pass
+
def with_retry(self, func, *args, **kwargs):
"""Run a method repeatedly in the face of transient ZK errors
"""
View
6 kazoo/zkclient.py
@@ -43,9 +43,6 @@ class WatchedEvent(namedtuple('WatchedEvent', ('type', 'state', 'path'))):
"""
class ZooKeeperClient(object):
-
- DEFAULT_TIMEOUT = 10000
-
"""A gevent-friendly wrapper of the Apache ZooKeeper zkpython client
TODO lots to do:
@@ -53,6 +50,9 @@ class ZooKeeperClient(object):
* disconnected state handling
* the rest of the operations
"""
+
+ DEFAULT_TIMEOUT = 10000
+
def __init__(self, hosts, watcher=None, timeout=10000):
self._hosts = hosts
self._watcher = watcher
Please sign in to comment.
Something went wrong with that request. Please try again.