From 15efd34ed215bbb6cdaafa77fbc5e9922b79fc3e Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Mon, 17 Aug 2015 10:26:32 +0000 Subject: reproducible: common.py: nest try/except clauses to really catch every possible sql error --- bin/reproducible_common.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'bin') diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py index 6ddcf398..653bff12 100755 --- a/bin/reproducible_common.py +++ b/bin/reproducible_common.py @@ -320,23 +320,24 @@ def start_udd_connection(): port = 5432 db = "udd" try: - log.debug("Starting connection to the UDD database") - conn = psycopg2.connect( - database=db, - user=username, - host=host, - password=password, - connect_timeout=5, - ) - except psycopg2.OperationalError as err: - if str(err) == 'timeout expired\n': - log.error('Connection to the UDD database replice timed out. ' - 'Probably the machine is offline or just unavailable.') - log.error('Failing nicely anyway, all queries will return an ' - 'empty response.') - return None - else: - raise + try: + log.debug("Starting connection to the UDD database") + conn = psycopg2.connect( + database=db, + user=username, + host=host, + password=password, + connect_timeout=5, + ) + except psycopg2.OperationalError as err: + if str(err) == 'timeout expired\n': + log.error('Connection to the UDD database replice timed out. ' + 'Maybe the machine is offline or just unavailable.') + log.error('Failing nicely anyway, all queries will return an ' + 'empty response.') + return None + else: + raise except: log.error('Erorr connecting to the UDD database replica.' + 'The full error is:') -- cgit v1.2.3-54-g00ecf