diff options
author | Joshua Harlow <harlowja@gmail.com> | 2014-08-31 19:43:14 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@gmail.com> | 2014-08-31 19:44:14 -0700 |
commit | 32c0c256f61925833cdfb2d247c606f9ad88785a (patch) | |
tree | a35cf7f47c8f314971d8b953c2b8723191050c51 | |
parent | 598198b83b30ec343e8002804145aa180654f56b (diff) | |
download | zake-32c0c256f61925833cdfb2d247c606f9ad88785a.tar.gz |
Expose the storage properties directly
Match the API that the client provides in that internal
properties are exposed directly, without copying so they
can be examined at the users own risk (ie, iteration of a
collection while its being mutated can be problematic).
-rw-r--r-- | zake/fake_storage.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/zake/fake_storage.py b/zake/fake_storage.py index 4d89cf6..ea56a72 100644 --- a/zake/fake_storage.py +++ b/zake/fake_storage.py @@ -94,18 +94,15 @@ class FakeStorage(object): @property def paths(self): - with self.lock: - return dict(self._paths) + return self._paths @property def sequences(self): - with self.lock: - return dict(self._sequences) + return self._sequences @property def clients(self): - with self._client_lock: - return self._clients.copy() + return self._clients def __getitem__(self, path): return self._paths[path] @@ -172,7 +169,9 @@ class FakeStorage(object): return len(removals) def inform(self, client, child_watches, data_watches, inform_self=True): - for other_client in self.clients: + with self._client_lock: + clients = self._clients.copy() + for other_client in clients: if not inform_self and other_client is client: continue other_client.fire_child_watches(child_watches) @@ -256,8 +255,8 @@ class FakeStorage(object): # data if the context manager fails (this makes it appear that the # operations done during the transaction either complete as a # group or do not complete). - paths = self.paths - sequences = self.sequences + paths = self._paths.copy() + sequences = self._sequences.copy() try: yield except Exception: |