From 04d6d26535a53e139479e19213a12a1538bdaafe Mon Sep 17 00:00:00 2001 From: Jake Mensch Date: Fri, 19 Jun 2020 20:06:27 -0400 Subject: [PATCH 1/2] fixed connection bug --- server/api/src/db/conn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/api/src/db/conn.py b/server/api/src/db/conn.py index 29fe8a95c..97b35be63 100644 --- a/server/api/src/db/conn.py +++ b/server/api/src/db/conn.py @@ -26,8 +26,7 @@ def fail(message): attempt = 0 while True: try: - with engine.connect(): - pass + engine.connect() except Exception: if attempt < ATTEMPTS: log(f'Could not connect to DB, retrying in {DELAY}') @@ -37,6 +36,7 @@ def fail(message): fail('Cannot connect to database.') else: + engine.dispose() return engine From a1747dca4eaf2e308dd7849450965aaeb4fa9b46 Mon Sep 17 00:00:00 2001 From: Jake Mensch Date: Fri, 19 Jun 2020 21:40:23 -0400 Subject: [PATCH 2/2] fix error when parsing json in ErrorHandler --- server/api/src/control/error_handler.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/api/src/control/error_handler.py b/server/api/src/control/error_handler.py index 309086f60..75da1f094 100644 --- a/server/api/src/control/error_handler.py +++ b/server/api/src/control/error_handler.py @@ -36,10 +36,15 @@ async def send_to_slack(self, request, trace, status_code): else: qs = '?{}'.format(request.query_string) - if request.json is None: + try: + json = request.json + except Exception: + json = None + + if json is None: params = '' else: - params = '\n{}'.format(dumps(request.json, indent=2)) + params = '\n{}'.format(dumps(json, indent=2)) message = f""" ```