diff options
author | Pjotr Prins | 2016-06-23 10:56:12 +0000 |
---|---|---|
committer | Pjotr Prins | 2016-06-23 10:56:12 +0000 |
commit | a3c32694806ffc212f987c99c20799526069d643 (patch) | |
tree | 77ff5c852dabce8e5fb2871e42d276f917f4ae47 | |
parent | 4095e7d4d12cd4c06aa839a8c47ba38fbb9d30e3 (diff) | |
download | genenetwork2-a3c32694806ffc212f987c99c20799526069d643.tar.gz |
views: close db handling
-rw-r--r-- | wqflask/wqflask/views.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 10e53e5e..bce1f755 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -26,9 +26,10 @@ import base64 import array import sqlalchemy from wqflask import app -from flask import (render_template, request, make_response, Response, - Flask, g, config, jsonify, redirect, url_for, - send_from_directory) +from flask import g, request, render_template +# from flask import (render_template, request, make_response, Response, +# Flask, g, config, jsonify, redirect, url_for, +# send_from_directory) from wqflask import search_results from wqflask import gsearch from wqflask import update_search_results @@ -73,8 +74,11 @@ def connect_db(): @app.teardown_appcontext def shutdown_session(exception=None): - logger.debug("remove db_session") - db_session.remove() + db = getattr(g, '_database', None) + if db is not None: + logger.debug("remove db_session") + db_session.remove() + g.db = None #@app.before_request #def trace_it(): |