ensure db connection is closed at the end of each thread
diff --git a/planetstack/openstack_observer/event_loop.py b/planetstack/openstack_observer/event_loop.py
index 9e8c7b4..12965bb 100644
--- a/planetstack/openstack_observer/event_loop.py
+++ b/planetstack/openstack_observer/event_loop.py
@@ -12,6 +12,7 @@
from collections import defaultdict
from core.models import *
from django.db.models import F, Q
+from django.db import connection
#from openstack.manager import OpenStackManager
from openstack.driver import OpenStackDriver
from util.logger import Logger, logging, logger
@@ -238,6 +239,7 @@
raise StepNotReady
def sync(self, S, deletion):
+ try:
step = self.step_lookup[S]
start_time=time.time()
@@ -337,6 +339,8 @@
except KeyError,e:
logger.info('Step %r is a leaf' % step)
pass
+ finally:
+ connection.close()
def run(self):
if not self.driver.enabled: