mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More useful printout when fail to open db
This commit is contained in:
parent
746191e4ca
commit
a3f24e5a2f
@ -8,6 +8,7 @@ Wrapper for multi-threaded access to a single sqlite database connection. Serial
|
|||||||
all calls.
|
all calls.
|
||||||
'''
|
'''
|
||||||
import sqlite3 as sqlite, traceback, time, uuid, sys, os
|
import sqlite3 as sqlite, traceback, time, uuid, sys, os
|
||||||
|
import repr as reprlib
|
||||||
from sqlite3 import IntegrityError, OperationalError
|
from sqlite3 import IntegrityError, OperationalError
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Queue
|
from Queue import Queue
|
||||||
@ -20,6 +21,7 @@ from calibre.utils.date import parse_date, isoformat
|
|||||||
from calibre import isbytestring, force_unicode
|
from calibre import isbytestring, force_unicode
|
||||||
from calibre.constants import iswindows, DEBUG
|
from calibre.constants import iswindows, DEBUG
|
||||||
from calibre.utils.icu import strcmp
|
from calibre.utils.icu import strcmp
|
||||||
|
from calibre import prints
|
||||||
|
|
||||||
global_lock = RLock()
|
global_lock = RLock()
|
||||||
|
|
||||||
@ -228,9 +230,13 @@ class DBThread(Thread):
|
|||||||
break
|
break
|
||||||
except OperationalError, err:
|
except OperationalError, err:
|
||||||
# Retry if unable to open db file
|
# Retry if unable to open db file
|
||||||
if 'unable to open' not in str(err) or i == 2:
|
e = str(err)
|
||||||
|
if 'unable to open' not in e or i == 2:
|
||||||
|
if 'unable to open' in e:
|
||||||
|
prints('Unable to open database for func',
|
||||||
|
func, reprlib.repr(args),
|
||||||
|
reprlib.repr(kwargs))
|
||||||
raise
|
raise
|
||||||
traceback.print_exc()
|
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
ok, res = False, (err, traceback.format_exc())
|
ok, res = False, (err, traceback.format_exc())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user