Commit 21a07727 authored by Stavros Sachtouris's avatar Stavros Sachtouris Committed by Giorgos Korfiatis
Browse files

Retry initializing database when it is locked

parent edf47a75
......@@ -306,7 +306,3 @@ class AgkyraCLI(cmd.Cmd):
else:
sys.stderr.write('Not running\n')
sys.stderr.flush()
def do_florist(self, line):
"""RUN FLORIST, RUN!"""
sys.stderr.write('RUN: %s\n' % STATUS)
......@@ -38,6 +38,7 @@ with open(os.path.join(CURPATH, 'ui_common.json')) as f:
UI_COMMON = json.load(f)
STATUS = UI_COMMON['STATUS']
def retry_on_locked_db(method, *args, **kwargs):
"""If DB is locked, wait and try again"""
wait = kwargs.get('wait', 0.2)
......@@ -68,7 +69,7 @@ class SessionHelper(object):
LOG.debug('Connect to db')
self.db = sqlite3.connect(self.session_db)
self._init_db_relation()
retry_on_locked_db(self._init_db_relation)
def _init_db_relation(self):
"""Create the session relation"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment