Skip to content

Commit

Permalink
Merge pull request #701 from hackforla/BACK-DBConnectionFix
Browse files Browse the repository at this point in the history
Back db connection fix
  • Loading branch information
adamkendis authored Jun 22, 2020
2 parents fd9a3a9 + a1747dc commit 6202cd5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions server/api/src/control/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
```
Expand Down
4 changes: 2 additions & 2 deletions server/api/src/db/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand All @@ -37,6 +36,7 @@ def fail(message):

fail('Cannot connect to database.')
else:
engine.dispose()
return engine


Expand Down

0 comments on commit 6202cd5

Please sign in to comment.