If an operational error occurs and we're just going to discard it and
retry, then at least log the error message to stderr.
Signed-off-by: John Admanski <jadmanski@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1494 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/db.py b/tko/db.py
index 656f267..2d992ac 100644
--- a/tko/db.py
+++ b/tko/db.py
@@ -90,7 +90,8 @@
while not success:
try:
result = function(*args, **dargs)
- except OperationalError:
+ except OperationalError, e:
+ self._log_operational_error(e)
stop_time = time.time()
elapsed_time = stop_time - start_time
if elapsed_time > self.query_timeout:
@@ -99,13 +100,20 @@
try:
self._random_delay()
self._init_db()
- except OperationalError:
- pass
+ except OperationalError, e:
+ self._log_operational_error(e)
else:
success = True
return result
+ def _log_operational_error(self, e):
+ msg = ("An operational error occured during a database "
+ "operation: %s" % str(e))
+ print >> sys.stderr, msg
+ sys.stderr.flush() # we want these msgs to show up immediately
+
+
def dprint(self, value):
if self.debug:
sys.stdout.write('SQL: ' + str(value) + '\n')