]> khamidou — GitHub mirrors - kite.git/commitdiff
fixed dumper bug
authorkarim hamidou <khamidou@gmail.com>
Thu, 1 May 2014 13:27:36 +0000 (15:27 +0200)
committerkarim hamidou <khamidou@gmail.com>
Thu, 1 May 2014 13:27:36 +0000 (15:27 +0200)
src/back/kite/filterdaemon.py
src/back/kite/jsonfile.py

index b9ece95dd0b2d6024923f64eb7affdbac107aba3..91401210ce824d3646e709d3096e7459d1dc0f26 100755 (executable)
@@ -70,8 +70,10 @@ class DumperThread(threading.Thread):
         while True:
             time.sleep(DUMPER_SLEEP_DURATION)
             for user in self.threads_index_cache:
+                print "dumper " + user
                 if self.threads_index_cache[user]["dirty"]:
-                    print "Dumping threads index for user %s" % user
+                    print "Dumping threads index for user %s at location %s " % (user, self.threads_index_cache[user]["threads_index"].path)
+
                     self.threads_index_cache[user]["threads_index"].save()
                     self.threads_index_cache[user]["dirty"] = False
             
@@ -114,8 +116,8 @@ class ProcessorThread(threading.Thread):
     def __init__(self, path, threads_index_cache):
         threading.Thread.__init__(self)
         self.path = path
-
         self.threads_index_cache = threads_index_cache
+
     def run(self):
         while True:
             while len(events_queue) != 0:
@@ -130,10 +132,11 @@ class ProcessorThread(threading.Thread):
                             print "Getting threads_index for user : %s" % username
                             self.threads_index_cache[username] = {"threads_index": threads_index, "dirty": True}
                         
-                        process_new_email(event["path"], threads_index_cache[username]["threads_index"].data)
-                        threads_index_cache[username]["dirty"] = True
-                    except IOError:
+                        process_new_email(event["path"], self.threads_index_cache[username]["threads_index"].data)
+                        self.threads_index_cache[username]["dirty"] = True
+                    except IOError as e:
                         # This may be a Postfix/Dovecot temporary file. Ignore it.
+                        print "caught ioerror %s" % e.strerror
                         pass
                     
             time.sleep(EVENTS_QUEUE_PROCESSING_DELAY)
index ac296973ec240708e3019f26bc89b692ba1ab877..92949dc64b62a261f4202b9b8966d8ebb5dba5d8 100644 (file)
@@ -29,11 +29,14 @@ class JsonFile(object):
         self.refresh()
 
     def refresh(self):
-        if self.path != None:
-            with FileLock(self.path):
-                fd = open(self.path, "r")
-                self.data = json.load(fd, object_hook=deserialize_datetime)
-                fd.close()
+        try:
+            if self.path != None:
+                with FileLock(self.path):
+                    fd = open(self.path, "r")
+                    self.data = json.load(fd, object_hook=deserialize_datetime)
+                    fd.close()
+        except IOError:
+            pass
      
     def save(self, path=None):
         if path == None: