parent
5a3ad09a04
commit
73bad8fa05
1 changed files with 6 additions and 3 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue