From 357347ce3adcc6450a51cb0ce34a677252d61340 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 20 Jun 2021 21:03:35 +0200 Subject: [PATCH] lower timeout on db reads --- copyparty/httpcli.py | 20 ++++++++++++++------ copyparty/u2idx.py | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index a910a1c7..d1f0f355 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -1770,11 +1770,16 @@ class HttpCli(object): _, rd = vn.get_dbv(rd) q = "select w from up where rd = ? and fn = ?" + r = None try: r = icur.execute(q, (rd, fn)).fetchone() - except: - args = s3enc(idx.mem_cur, rd, fn) - r = icur.execute(q, args).fetchone() + except Exception as ex: + if "database is locked" not in str(ex): + try: + args = s3enc(idx.mem_cur, rd, fn) + r = icur.execute(q, args).fetchone() + except: + self.log("tag list error:\n" + min_ex()) tags = {} f["tags"] = tags @@ -1784,9 +1789,12 @@ class HttpCli(object): w = r[0][:16] q = "select k, v from mt where w = ? and k != 'x'" - for k, v in icur.execute(q, (w,)): - taglist[k] = True - tags[k] = v + try: + for k, v in icur.execute(q, (w,)): + taglist[k] = True + tags[k] = v + except: + self.log("tag read error:\n" + min_ex()) if icur: taglist = [k for k in vn.flags.get("mte", "").split(",") if k in taglist] diff --git a/copyparty/u2idx.py b/copyparty/u2idx.py index 49f4a860..474d21a5 100644 --- a/copyparty/u2idx.py +++ b/copyparty/u2idx.py @@ -66,7 +66,7 @@ class U2idx(object): if not os.path.exists(db_path): return None - cur = sqlite3.connect(db_path).cursor() + cur = sqlite3.connect(db_path, 2).cursor() self.cur[ptop] = cur return cur