'There are multiple processes accessing the sqlite3 database
which in turn denies concurrent accesses.
To try to mitigate the issue we retry the query a few times
before bailing out.
See #19733'

def locked_retry(self, method, *args, **kwargs):

    retries = 0
    while True:
        try:
            rv = method(self, *args, **kwargs)
        except OperationalError as e:
            if ('locked' not in str(e)):
                raise
            if (retries < 5):
                time.sleep(0.3)
                retries += 1
                continue
            else:
                try:
                    from freenasUI.freeadmin.utils import log_db_locked
                    log_db_locked()
                except Exception:
                    pass
                raise e
        break
    return rv
