Increase number of attempts to write to Kodi DB

- Partially fixes #593
This commit is contained in:
croneter 2019-01-13 14:29:35 +01:00
parent 5a3ad09a04
commit 73bad8fa05

View file

@ -7,17 +7,20 @@ from functools import wraps
from .. import utils, path_ops, app from .. import utils, path_ops, app
KODIDB_LOCK = Lock() KODIDB_LOCK = Lock()
DB_WRITE_ATTEMPTS = 10
def catch_operationalerrors(method): def catch_operationalerrors(method):
@wraps(method) @wraps(method)
def wrapped(*args, **kwargs): def wrapped(*args, **kwargs):
attempts = 3 attempts = DB_WRITE_ATTEMPTS
while True: while True:
try: try:
return method(*args, **kwargs) return method(*args, **kwargs)
except utils.OperationalError: except utils.OperationalError as err:
app.APP.monitor.waitForAbort(0.01) if 'database is locked' not in err:
raise
app.APP.monitor.waitForAbort(0.05)
attempts -= 1 attempts -= 1
if attempts == 0: if attempts == 0:
raise raise