From: karim hamidou Date: Thu, 1 May 2014 13:27:36 +0000 (+0200) Subject: fixed dumper bug X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=488014da2d4b4bc38148438510b75ea7570cbbad;p=kite.git fixed dumper bug --- diff --git a/src/back/kite/filterdaemon.py b/src/back/kite/filterdaemon.py index b9ece95..9140121 100755 --- a/src/back/kite/filterdaemon.py +++ b/src/back/kite/filterdaemon.py @@ -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) diff --git a/src/back/kite/jsonfile.py b/src/back/kite/jsonfile.py index ac29697..92949dc 100644 --- a/src/back/kite/jsonfile.py +++ b/src/back/kite/jsonfile.py @@ -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: