Now the sql connections are closed automatically when the requests are finished
This commit is contained in:
parent
6c437d4cac
commit
79a7f2291d
2 changed files with 16 additions and 2 deletions
|
|
@ -835,8 +835,19 @@ class WebModel:
|
|||
|
||||
@staticmethod
|
||||
def close():
|
||||
|
||||
connection_to_delete=[]
|
||||
|
||||
WebModel.make_connection=SqlClass.connect_to_db
|
||||
SqlClass.close(SqlClass)
|
||||
|
||||
for key in SqlClass.connection:
|
||||
SqlClass.close(SqlClass, key)
|
||||
#connection_to_delete.append(key)
|
||||
|
||||
SqlClass.connection={}
|
||||
|
||||
#for key in connection_to_delete:
|
||||
#del SqlClass.connection[key]
|
||||
|
||||
@staticmethod
|
||||
def escape_sql(value):
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from bottle import route, get, post, run, default_app, abort, request, static_fi
|
|||
from settings import config, modules
|
||||
from beaker.middleware import SessionMiddleware
|
||||
from mimetypes import guess_type
|
||||
from paramecio.cromosoma.webmodel import WebModel
|
||||
|
||||
#Prepare links for static.
|
||||
#WARNING: only use this feature in development, not in production.
|
||||
|
|
@ -118,7 +119,9 @@ if config.ssl==True:
|
|||
|
||||
app = application = default_app()
|
||||
|
||||
app.add_hook('before_request', print_cookie)
|
||||
#app.add_hook('before_request', print_cookie)
|
||||
|
||||
app.add_hook('after_request', WebModel.close)
|
||||
|
||||
if config.session_enabled==True:
|
||||
#Create dir for sessions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue