From 21cf625f6970c001c9f14bdbc603a104e544b9e1 Mon Sep 17 00:00:00 2001
From: Marek Siarkowicz <mareksiarkowicz@gmail.com>
Date: Mon, 15 Jun 2015 00:17:20 +0200
Subject: Don't fetch notification for recent fetched paths.

---
 resource_manager.py | 13 +++++++------
 1 file 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
-- 
cgit v1.2.1