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
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:
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)
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: