[API][ADMIN_API] SQLAlchemy bind cleanups

Change-Id: I88b62f7dce663fe1b62b657cc5b51d7fdce60e33
This commit is contained in:
Andrew Hutchings
2013-07-05 11:15:18 +01:00
parent b5fbeabc56
commit d3b9bd8357
2 changed files with 4 additions and 2 deletions

View File

@@ -148,7 +148,7 @@ class db_session(object):
self.session = None
def __enter__(self):
self.session = sessionmaker(bind=engine, class_=RoutingSession)()
self.session = sessionmaker(class_=RoutingSession)()
return self.session
def __exit__(self, type, value, traceback):

View File

@@ -139,6 +139,8 @@ class Node(DeclarativeBase):
class RoutingSession(Session):
# TODO: writes deadlock on multi galera due to:
# http://tinyurl.com/9h6qlly
def get_bind(self, mapper=None, clause=None):
return random.choice(engines)
@@ -148,7 +150,7 @@ class db_session(object):
self.session = None
def __enter__(self):
self.session = sessionmaker(bind=engine, class_=RoutingSession)()
self.session = sessionmaker(class_=RoutingSession)()
return self.session
def __exit__(self, type, value, traceback):