Disconnect from read slaves when the request ends.
This commit is contained in:
parent
13de458320
commit
9932a8199f
1 changed files with 7 additions and 2 deletions
|
@ -2,11 +2,12 @@ import logging
|
|||
import logging.config
|
||||
import uuid
|
||||
|
||||
from peewee import Proxy
|
||||
|
||||
from app import app as application
|
||||
from flask import request, Request
|
||||
from util.names import urn_generator
|
||||
|
||||
from data.model import db as model_db
|
||||
from data.model import db as model_db, read_slave
|
||||
|
||||
# Turn off debug logging for boto
|
||||
logging.getLogger('boto').setLevel(logging.CRITICAL)
|
||||
|
@ -76,6 +77,10 @@ def close_db(exc):
|
|||
logger.debug('Disconnecting from database.')
|
||||
db.close()
|
||||
|
||||
if read_slave.obj is not None and not read_slave.is_closed():
|
||||
logger.debug('Disconnecting from read slave.')
|
||||
read_slave.close()
|
||||
|
||||
application.teardown_request(close_db)
|
||||
application.request_class = RequestWithId
|
||||
|
||||
|
|
Reference in a new issue