Thread safe method to create directory for db
This commit is contained in:
parent
9b1f6337c3
commit
98c98fbac7
1 changed files with 4 additions and 1 deletions
|
@ -108,9 +108,12 @@ class Db(object):
|
|||
if self not in opened_dbs:
|
||||
opened_dbs.append(self)
|
||||
s = time.time()
|
||||
if not os.path.isdir(self.db_dir): # Directory not exist yet
|
||||
try: # Directory not exist yet
|
||||
os.makedirs(self.db_dir)
|
||||
self.log.debug("Created Db path: %s" % self.db_dir)
|
||||
except OSError as err:
|
||||
if err.errno != errno.EEXIST:
|
||||
raise err
|
||||
if not os.path.isfile(self.db_path):
|
||||
self.log.debug("Db file not exist yet: %s" % self.db_path)
|
||||
self.conn = sqlite3.connect(self.db_path, isolation_level="DEFERRED", check_same_thread=False)
|
||||
|
|
Loading…
Reference in a new issue