Prevent repeated db connect calls

Only call database.connect() if database.is_closed()
Prevents errors if _db_connect is triggered twice
This commit is contained in:
Craig Citro 2021-06-26 18:41:26 -05:00 committed by Blake Blackshear
parent 7ad8b8298d
commit 7ddba4fc59

View File

@ -47,7 +47,8 @@ def create_app(
@app.before_request
def _db_connect():
database.connect()
if database.is_closed():
database.connect()
@app.teardown_request
def _db_close(exc):