Permalink
Browse files

Update to use safe calls in more spots. Update version, spit out more…

… detail on tests.
  • Loading branch information...
1 parent 582a8ca commit c3c96d56f7136f2401b247fa220cb5f3a29896f2 @bbangert bbangert committed May 4, 2012
Showing with 9 additions and 8 deletions.
  1. +1 −1 Makefile
  2. +1 −1 setup.py
  3. +7 −6 zktools/locking.py
View
@@ -63,5 +63,5 @@ build: $(BIN)/python zookeeper
test:
$(BIN)/zookeeper/bin/zkServer.sh start $(HERE)/zoo.cfg
- $(NOSE) --with-coverage --cover-package=$(APPNAME) --cover-inclusive $(APPNAME)
+ $(NOSE) -v --with-coverage --cover-package=$(APPNAME) --cover-inclusive $(APPNAME)
$(BIN)/zookeeper/bin/zkServer.sh stop $(HERE)/zoo.cfg
View
@@ -1,4 +1,4 @@
-__version__ = '0.2.1'
+__version__ = '0.3'
import os
View
@@ -259,7 +259,7 @@ def release(self):
"""
self._locks.revoked = []
try:
- self._zk.delete(self._locks.lock_node)
+ safe_call(self._zk, 'delete', self._locks.lock_node)
del self._locks.lock_node
return True
except (zookeeper.NoNodeException, AttributeError):
@@ -279,7 +279,7 @@ def has_lock(self):
znode = self._locks.lock_node
keyname = znode[znode.rfind('/') + 1:]
# Get all the children of the node
- children = self._zk.get_children(self._locknode)
+ children = safe_call(self._zk, 'get_children', self._locknode)
children.sort(key=lambda val: val[val.rfind('-') + 1:])
if keyname not in children:
return False
@@ -300,10 +300,10 @@ def clear(self):
:rtype: bool
"""
- children = self._zk.get_children(self._locknode)
+ children = safe_call(self._zk, 'get_children', self._locknode)
for child in children:
try:
- self._zk.delete(self._locknode + '/' + child)
+ safe_call(self._zk, 'delete', self._locknode + '/' + child)
except zookeeper.NoNodeException:
pass
@@ -319,13 +319,14 @@ def revoke_all(self):
"""
# Get all the children of the node
- children = self._zk.get_children(self._locknode)
+ children = safe_call(self._zk, 'get_children', self._locknode)
if not children:
return False
for child in children:
try:
- self._zk.set(self._locknode + '/' + child, "unlock")
+ safe_call(self._zk, 'set', self._locknode + '/' + child,
+ "unlock")
except zookeeper.NoNodeException:
pass
return True

0 comments on commit c3c96d5

Please sign in to comment.