diff options
author | 2018-06-13 14:41:40 +0100 | |
---|---|---|
committer | 2018-06-13 14:41:40 +0100 | |
commit | 2b8a6687f03972b53f855e2bf996de0387c51ccf (patch) | |
tree | 4ecb83011fc055cfc951b8f637416244415e9c74 /pysite | |
parent | [CI] Fix missing backslash (diff) |
[DB] Attempt reconnection if current connection was lost
Diffstat (limited to 'pysite')
-rw-r--r-- | pysite/database.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pysite/database.py b/pysite/database.py index a8c6c559..bb0c3415 100644 --- a/pysite/database.py +++ b/pysite/database.py @@ -226,7 +226,14 @@ class RethinkDB: """ if not new_connection: - result = query.run(self.conn) + try: + result = query.run(self.conn) + except rethinkdb.ReqlDriverError as e: + if e.message == "Connection is closed.": + self.log.warning("Connection was closed, attempting with a new connection...") + result = query.run(self.get_connection(connect_database)) + else: + raise else: result = query.run(self.get_connection(connect_database)) |