Make sure builders close the db handle when no work comes in and make the metrics transaction smaller in scope

This commit is contained in:
Joseph Schorr 2014-10-24 11:40:02 -04:00
parent fb2470615b
commit c06f57a6e7
2 changed files with 8 additions and 6 deletions

View file

@ -122,6 +122,8 @@ class Worker(object):
with self._current_item_lock:
current_queue_item = self.current_queue_item
if current_queue_item is None:
# Close the db handle.
self._close_db_handle()
break
logger.debug('Queue gave us some work: %s', current_queue_item.body)
@ -143,7 +145,7 @@ class Worker(object):
self._stop.set()
finally:
# Close the db handle periodically
# Close the db handle.
self._close_db_handle()
if not self._stop.is_set():