[Qa-jenkins-scm] [jenkins.debian.net] 01/01: reproducible debian: make sqlite3 locking errors less noisy
Holger Levsen
holger at layer-acht.org
Fri Aug 19 19:17:30 UTC 2016
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to branch master
in repository jenkins.debian.net.
commit 32f1504173923bf578786b0d6f586a04a4447310
Author: Valerie R Young <spectranaut at riseup.net>
Date: Fri Aug 19 15:13:52 2016 -0400
reproducible debian: make sqlite3 locking errors less noisy
Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
bin/reproducible_common.py | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index dcbe05e..985f2eb 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -30,6 +30,7 @@ from subprocess import call, check_call
from tempfile import NamedTemporaryFile
from datetime import datetime, timedelta
from sqlalchemy import MetaData, Table, sql, create_engine
+from sqlalchemy.exc import NoSuchTableError, OperationalError
DEBUG = False
QUIET = False
@@ -365,7 +366,7 @@ def db_table(table_name):
"""
try:
return Table(table_name, DB_METADATA, autoload=True)
- except sqlalchemy.exc.NoSuchTableError:
+ except NoSuchTableError:
log.error("Table %s does not exist or schema for %s could not be loaded",
table_name, REPRODUCIBLE_DB)
raise
@@ -384,9 +385,16 @@ def query_db(query):
"""
try:
result = conn_db.execute(query)
- except:
- print_critical_message('Error executing this query:\n' + query)
- raise
+ except OperationalError as ex:
+ # if this sqlalchemy.exc.OperationalError was caused by a sqlite3
+ # database locking error, the error will have the following format:
+ if ex.orig and ex.orig.args and ex.orig.args[0] == "database is locked":
+ print_critical_message('SQLite database locked, could not execute ' +
+ 'query:\n"%s"\nExiting script.' % query)
+ exit(1)
+ else:
+ print_critical_message('Error executing this query:\n' + query)
+ raise
if result.returns_rows:
return result.fetchall()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git
More information about the Qa-jenkins-scm
mailing list