catch uncaught exceptions

Exceptions in these two places will hang the entire graph service

Change-Id: Id81b97dd04aee14ddd7486703491112562fa1c83
This commit is contained in:
Idan Hefetz 2018-03-12 12:48:47 +00:00
parent 5f4628c332
commit 346184a489
2 changed files with 12 additions and 5 deletions

View File

@ -102,11 +102,11 @@ class GraphCloneWorkerBase(os_service.Service):
def _read_queue(self):
while True:
next_task = self._task_queue.get()
if next_task is POISON_PILL:
self._task_queue.task_done()
break
try:
next_task = self._task_queue.get()
if next_task is POISON_PILL:
self._task_queue.task_done()
break
self.do_task(next_task)
except Exception as e:
LOG.exception("Graph may not be in sync: exception %s", e)

View File

@ -96,10 +96,17 @@ PRIORITY_DELAY = 0.05
class TwoPriorityListener(object):
def __init__(self, conf, do_work_func, topic_low, topic_high):
self._conf = conf
self._do_work_func = do_work_func
self._lock = threading.Lock()
self._high_event_finish_time = 0
def do_work(event):
try:
return do_work_func(event)
except Exception as e:
LOG.exception('Got Exception %s', e)
self._do_work_func = do_work
self._low_pri_listener = self._init_listener(
topic_low, self._do_low_priority_work)
self._high_pri_listener = self._init_listener(