[fix] avoid a possible thread problem

This commit is contained in:
Laurent Peuch 2016-06-24 08:06:52 +02:00
parent 5fba284260
commit 5eda0fe20e

View file

@ -74,7 +74,9 @@ class Journal(object):
self.name = name self.name = name
self.category = category self.category = category
self.first_write = True self.first_write = True
self.started_at = None
# this help uniformise file name and avoir threads concurrency errors
self.started_at = datetime.now()
self.path = os.path.join(JOURNALS_PATH, category) self.path = os.path.join(JOURNALS_PATH, category)
@ -101,8 +103,6 @@ class Journal(object):
self.fd.flush() self.fd.flush()
def _do_first_write(self): def _do_first_write(self):
self.started_at = datetime.now()
if not os.path.exists(self.path): if not os.path.exists(self.path):
os.makedirs(self.path) os.makedirs(self.path)