diff options
author | Frederick Muriuki Muriithi | 2022-04-14 08:56:31 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-04-14 08:59:55 +0300 |
commit | 58101923291172e9999ffc607d5f3d1b9507ccfb (patch) | |
tree | b81456937f2c69d2235336bd63197f0307f9d00d /wqflask | |
parent | 47686b74aa4ca4f1dee5c7174b4f4dc54b1a1de8 (diff) | |
download | genenetwork2-58101923291172e9999ffc607d5f3d1b9507ccfb.tar.gz |
Debug: Add logging to track db connection creation and stoppingdebug-too-many-connections-error
As part of debugging the "Too many connections" error to the database,
this commit adds logging to track the creation of connections to the
database, and their eventual closing.
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/views.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 2138146c..fdb49c7f 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -110,6 +110,9 @@ logger = utility.logger.getLogger(__name__) def connect_db(): db = getattr(g, '_database', None) if request.endpoint not in ("static", "js") and db is None: + logger.debug( + f"Creating a database connection\n" + f"\t\tfor request: {request.endpoint}") g.db = g._database = sqlalchemy.create_engine( SQL_URI, encoding="latin1") @@ -118,8 +121,10 @@ def connect_db(): def shutdown_session(exception=None): db = getattr(g, '_database', None) if db is not None: + logger.debug(f"Removing the session") g.db.dispose() g.db = None + logger.debug(f"g.db: {g.db}\n\tg._database: {g._database}") @app.errorhandler(Exception) |