Check if session in transaction before closing

JIRA:NCP-1715

According to the docs this is maybe 'okay' but there is a better way
using listeners and etc.
See: http://tinyurl.com/qyae778
This commit is contained in:
Justin Hammond
2015-10-02 12:24:58 -05:00
parent 3416a558f2
commit 2670f1ebc4

View File

@@ -111,10 +111,11 @@ qres_reg.ResourceRegistry.get_instance().register_resources(quark_resources)
def sessioned(func):
def _wrapped(self, context, *args, **kwargs):
res = func(self, context, *args, **kwargs)
context.session.close()
# NOTE(mdietz): Forces neutron to get a fresh session
# if it needs it after our call
context._session = None
if not context.session.is_active:
context.session.close()
# NOTE(mdietz): Forces neutron to get a fresh session
# if it needs it after our call
context._session = None
return res
return _wrapped