one sqlalchemy session per thread

This commit is contained in:
j 2014-08-09 18:14:14 +02:00
commit 8b46a85d56
15 changed files with 140 additions and 102 deletions

View file

@ -17,6 +17,7 @@ from functools import wraps
import logging
logger = logging.getLogger('oxtornado')
import db
def json_response(data=None, status=200, text='ok'):
if not data:
@ -86,7 +87,7 @@ def api_task(app, request, callback):
logger.debug('API %s %s', action, data)
f = actions.get(action)
if f:
with app.app_context():
with db.session():
try:
response = f(data)
except: