From e4af13bbd5581529e6f880b374cb185594b0823e Mon Sep 17 00:00:00 2001 From: croneter Date: Thu, 17 Jan 2019 19:30:55 +0100 Subject: [PATCH] Try even longer to write to Kodi database - Partially fixes #593 --- resources/lib/kodi_db/common.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/lib/kodi_db/common.py b/resources/lib/kodi_db/common.py index dc9dafea..79a9fcba 100644 --- a/resources/lib/kodi_db/common.py +++ b/resources/lib/kodi_db/common.py @@ -7,10 +7,16 @@ from functools import wraps from .. import utils, path_ops, app KODIDB_LOCK = Lock() -DB_WRITE_ATTEMPTS = 10 +DB_WRITE_ATTEMPTS = 100 def catch_operationalerrors(method): + """ + sqlite.OperationalError is raised immediately if another DB connection + is open, reading something that we're trying to change + + So let's catch it and try again + """ @wraps(method) def wrapped(*args, **kwargs): attempts = DB_WRITE_ATTEMPTS @@ -20,7 +26,9 @@ def catch_operationalerrors(method): except utils.OperationalError as err: if 'database is locked' not in err: raise - app.APP.monitor.waitForAbort(0.05) + if app.APP.monitor.waitForAbort(0.1): + # PKC needs to quit + return attempts -= 1 if attempts == 0: # Reraise in order to NOT catch nested OperationalErrors