summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2014-08-31 01:58:14 -0700
committerJoshua Harlow <harlowja@gmail.com>2014-08-31 01:58:14 -0700
commit4e2ae9c7e879094a61f6bb26281804ec857944ad (patch)
tree7ccc97107a6d5c5853a76d18dba4ceedd7b6e6dc
parentc15379e1b3d311413c60f1ddbf102a9cb2746be0 (diff)
downloadzake-4e2ae9c7e879094a61f6bb26281804ec857944ad.tar.gz
Do the watch connected checking in the fire method
-rw-r--r--zake/fake_client.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/zake/fake_client.py b/zake/fake_client.py
index 2a97dff..f4dc75c 100644
--- a/zake/fake_client.py
+++ b/zake/fake_client.py
@@ -349,23 +349,22 @@ class FakeClient(object):
self._listeners.discard(listener)
def fire_child_watches(self, child_watches):
- if not self._connected:
- return
for (paths, event) in child_watches:
self._fire_watches(paths, event, self._child_watches)
def fire_data_watches(self, data_watches):
- if not self._connected:
- return
for (paths, event) in data_watches:
self._fire_watches(paths, event, self._data_watches)
def _fire_watches(self, paths, event, watch_source):
for path in reversed(sorted(paths)):
- with self._watches_lock:
- watches = list(watch_source.pop(path, []))
- for w in watches:
- self.handler.dispatch_callback(utils.make_cb(w, [event]))
+ with self._open_close_lock:
+ if self._connected:
+ with self._watches_lock:
+ watches = list(watch_source.pop(path, []))
+ for w in watches:
+ cb = utils.make_cb(w, [event])
+ self.handler.dispatch_callback(cb)
def transaction(self):
return FakeTransactionRequest(self)