mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #4264 (Intermittent Database Exception)
This commit is contained in:
parent
2346be7553
commit
059b4c646a
@ -8,7 +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
|
import sqlite3 as sqlite, traceback, time, uuid
|
||||||
from sqlite3 import IntegrityError
|
from sqlite3 import IntegrityError, OperationalError
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Queue
|
from Queue import Queue
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
@ -138,8 +138,17 @@ class DBThread(Thread):
|
|||||||
ok, res = False, (err, traceback.format_exc())
|
ok, res = False, (err, traceback.format_exc())
|
||||||
else:
|
else:
|
||||||
func = getattr(self.conn, func)
|
func = getattr(self.conn, func)
|
||||||
|
try:
|
||||||
|
for i in range(3):
|
||||||
try:
|
try:
|
||||||
ok, res = True, func(*args, **kwargs)
|
ok, res = True, func(*args, **kwargs)
|
||||||
|
break
|
||||||
|
except OperationalError, err:
|
||||||
|
# Retry if unable to open db file
|
||||||
|
if 'unable to open' not in str(err) or i == 2:
|
||||||
|
raise
|
||||||
|
traceback.print_exc()
|
||||||
|
time.sleep(0.5)
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
ok, res = False, (err, traceback.format_exc())
|
ok, res = False, (err, traceback.format_exc())
|
||||||
self.results.put((ok, res))
|
self.results.put((ok, res))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user