[conduit] don't die fatally on sqlite errors
- From: John Stowers <jstowers src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [conduit] don't die fatally on sqlite errors
- Date: Fri, 20 Nov 2009 15:34:24 +0000 (UTC)
commit 5b45bf35e421bf273a3aed42079ad389b8f3e08b
Author: John Stowers <john stowers gmail com>
Date: Fri Nov 20 16:13:58 2009 +0100
don't die fatally on sqlite errors
conduit/Database.py | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/conduit/Database.py b/conduit/Database.py
index a7dd072..b5d1b78 100755
--- a/conduit/Database.py
+++ b/conduit/Database.py
@@ -294,6 +294,7 @@ class ThreadSafeGenericDB(Thread, GenericDB):
def run(self):
GenericDB._open(self)
+ self.broken = False
while not self.stopped:
req, args, res, operation = self.reqs.get()
if req=='--stop--':
@@ -301,7 +302,16 @@ class ThreadSafeGenericDB(Thread, GenericDB):
elif req=='--save--':
self.db.commit()
else:
- self.cur.execute(req, args)
+ try:
+ self.cur.execute(req, args)
+ except sqlite.ProgrammingError:
+ log.critical("sqlite syntax error: %s" % req, exc_info=True)
+ self.stopped = True
+ self.broken = True
+ except:
+ log.critical("unknown sqlite error", exc_info=True)
+ self.stopped = True
+ self.broken = True
#res is used to return a result to the caller
#in a blocking way
@@ -315,8 +325,9 @@ class ThreadSafeGenericDB(Thread, GenericDB):
else:
assert(False)
- self.cur.close()
- self.db.close()
+ if not self.broken:
+ self.cur.close()
+ self.db.close()
def execute(self, req, args=(), res=None, operation=""):
if self.DEBUG: log.debug(req)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]