Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ZooKeeper: Make reduction of data optional in LiveList.get().

If we need the raw list of objects so that we can know what objects can
be deleted etc. then we'll need to disable the reduction.
  • Loading branch information...
commit d896b9a71f6532f0c0a2a85abd7bf0809cc870b0 1 parent cf527d1
Neil Williams spladug authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 r2/r2/lib/
14 r2/r2/lib/
@@ -91,16 +91,20 @@ def __init__(self, client, root, map_fn=None, reduce_fn=lambda L: L,
def watcher(children):
- = self._normalize_children(children)
+ = self._normalize_children(children, reduce=True)
def _nodepath(self, item):
escaped = urllib.quote(str(item), safe=":")
return os.path.join(self.root, escaped)
- def _normalize_children(self, children):
+ def _normalize_children(self, children, reduce):
unquoted = (urllib.unquote(c) for c in children)
mapped = map(self.map_fn, unquoted)
- return list(self.reduce_fn(mapped))
+ if reduce:
+ return list(self.reduce_fn(mapped))
+ else:
+ return list(mapped)
def add(self, item):
path = self._nodepath(item)
@@ -114,9 +118,9 @@ def remove(self, item):
except NoNodeException:
raise ValueError("not in list")
- def get(self):
+ def get(self, reduce=True):
children = self.client.get_children(self.root)
- return self._normalize_children(children)
+ return self._normalize_children(children, reduce)
def __iter__(self):
if not self.is_watching:
Please sign in to comment.
Something went wrong with that request. Please try again.