diff -r 927d035b6921 -r e45bf9baa7b7 server/sqlutils.py --- a/server/sqlutils.py Tue Jan 07 15:10:57 2014 +0100 +++ b/server/sqlutils.py Tue Feb 04 15:06:25 2014 +0100 @@ -299,7 +299,7 @@ """ cnx_wrap = ConnectionWrapper - def __init__(self, source_config): + def __init__(self, source_config, repairing=False): try: self.dbdriver = source_config['db-driver'].lower() dbname = source_config['db-name'] @@ -328,6 +328,14 @@ if self.dbdriver == 'sqlite': self.cnx_wrap = SqliteConnectionWrapper self.dbhelper.dbname = abspath(self.dbhelper.dbname) + if not repairing: + statement_timeout = int(source_config.get('db-statement-timeout', 0)) + if statement_timeout > 0: + def set_postgres_timeout(cnx): + cnx.cursor().execute('SET statement_timeout to %d' % statement_timeout) + cnx.commit() + postgres_hooks = SQL_CONNECT_HOOKS['postgres'] + postgres_hooks.append(set_postgres_timeout) def wrapped_connection(self): """open and return a connection to the database, wrapped into a class