diff options
author | Marek Siarkowicz <mareksiarkowicz@gmail.com> | 2015-06-15 00:17:20 +0200 |
---|---|---|
committer | Marek Siarkowicz <mareksiarkowicz@gmail.com> | 2015-06-15 00:17:20 +0200 |
commit | 21cf625f6970c001c9f14bdbc603a104e544b9e1 (patch) | |
tree | a7279a0c6c498dfe2ca221fca2b6f3b27517954e | |
parent | e130a18d3c46f311d095819ab901b2fca57fcea3 (diff) | |
download | pyParrotZikTCP-21cf625f6970c001c9f14bdbc603a104e544b9e1.tar.xz pyParrotZikTCP-21cf625f6970c001c9f14bdbc603a104e544b9e1.zip |
Don't fetch notification for recent fetched paths.
Diffstat (limited to '')
-rw-r--r-- | resource_manager.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/resource_manager.py b/resource_manager.py index fb3b5f3..f0703ac 100644 --- a/resource_manager.py +++ b/resource_manager.py @@ -47,9 +47,9 @@ class ResourceManagerBase(object): self.sock = "" return else: - return self.get_answer() + return self.get_answer(message) - def get_answer(self): + def get_answer(self, message): data = self.receive_message() notifications = [] while not data.answer: @@ -58,14 +58,15 @@ class ResourceManagerBase(object): else: raise AssertionError('Unknown response') data = self.receive_message() - self.handle_notifications(notifications) + self.handle_notifications(notifications, message.resource) return data.answer - def handle_notifications(self, notifications): + def handle_notifications(self, notifications, resource): paths = map(itemgetter('path'), notifications) clean_paths = set(map(self._clean_path, paths)) for path in clean_paths: - self.fetch(path) + if resource != path: + self.fetch(path) def _clean_path(self, path): return path.rsplit('/', 1)[0].encode('utf-8') @@ -95,7 +96,7 @@ class GenericResourceManager(ResourceManagerBase): def get_resource_manager(self, resource_manager_class): resource_manager = resource_manager_class(self.sock, self.resource_values) - resource_manager.handle_notifications(self.notifications) + resource_manager.handle_notifications(self.notifications, '/api/software/version') return resource_manager @property |