summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichiel Johan Baird <michiel@asana.com>2016-04-20 19:32:01 -0700
committerMichiel Johan Baird <michiel@asana.com>2016-04-20 19:32:01 -0700
commitf4d7ebcec070e9dd109ab9a156363bdf24909992 (patch)
tree10fc57f1a90570ddf6ae9747b102a9366a64ba9d
parent92b4dba7bfff675a65ae63ab3706d91eb93cf806 (diff)
downloadkazoo-f4d7ebcec070e9dd109ab9a156363bdf24909992.tar.gz
Added test add fixed a regression
-rw-r--r--kazoo/client.py3
-rw-r--r--kazoo/recipe/watchers.py3
-rw-r--r--kazoo/tests/test_client.py16
3 files changed, 20 insertions, 2 deletions
diff --git a/kazoo/client.py b/kazoo/client.py
index c052d55..7f49d2e 100644
--- a/kazoo/client.py
+++ b/kazoo/client.py
@@ -193,7 +193,8 @@ class KazooClient(object):
self._state = KeeperState.CLOSED
self.state = KazooState.LOST
self.state_listeners = set()
-
+ self._child_watchers = defaultdict(set)
+ self._data_watchers = defaultdict(set)
self._reset()
self.read_only = read_only
diff --git a/kazoo/recipe/watchers.py b/kazoo/recipe/watchers.py
index ad585da..4324f6c 100644
--- a/kazoo/recipe/watchers.py
+++ b/kazoo/recipe/watchers.py
@@ -338,7 +338,8 @@ class ChildrenWatch(object):
raise
def _watcher(self, event):
- self._get_children(event)
+ if event.type != "NONE":
+ self._get_children(event)
def _session_watcher(self, state):
if state in (KazooState.LOST, KazooState.SUSPENDED):
diff --git a/kazoo/tests/test_client.py b/kazoo/tests/test_client.py
index b540e68..fcbb919 100644
--- a/kazoo/tests/test_client.py
+++ b/kazoo/tests/test_client.py
@@ -414,6 +414,22 @@ class TestConnection(KazooTestCase):
client._state = oldstate
client._connection._write_sock = None
+ def test_watch_trigger_expire(self):
+ client = self.client
+ cv = self.make_event()
+
+ client.create("/test", b"")
+
+ def test_watch(event):
+ cv.set()
+
+ client.get("/test/", watch=test_watch)
+ self.expire_session(self.make_event)
+
+
+ cv.wait(3)
+ assert cv.is_set()
+
class TestClient(KazooTestCase):
def _makeOne(self, *args):