Skip to content
Snippets Groups Projects
Commit 4c06b2e3 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #8887: check validity of connection. reconnect if needed

parent d2b5d525
No related branches found
No related tags found
No related merge requests found
......@@ -80,8 +80,11 @@ class MoMDatabaseWrapper:
# try a simple select
# if it fails, reconnect
cursor = self.conn.cursor()
cursor.execute('''SELECT * FROM project;''')
cursor.fetchall()
cursor.execute('''SELECT id FROM project;''')
if len(cursor.fetchall()) == 0:
logger.warning('unexpected answer while checking connection. reconnecting in 1 sec...')
time.sleep(1)
self._connect()
except (OperationalError, AttributeError) as e:
if isinstance(e, OperationalError):
logger.error(str(e))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment