parallel evaluation fixes
worker call task_done also on failure. manager to close queues once not needed. Change-Id: Id5e001a020c91320d4176ccbd67c4a814a3ba6a8
This commit is contained in:
parent
f065416545
commit
9ea04388a6
@ -27,6 +27,7 @@ LOG = log.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
START_EVALUATION = 'start_evaluation'
|
START_EVALUATION = 'start_evaluation'
|
||||||
|
POISON_PILL = None
|
||||||
|
|
||||||
|
|
||||||
class EvaluatorManager(EvaluatorBase):
|
class EvaluatorManager(EvaluatorBase):
|
||||||
@ -85,7 +86,9 @@ class EvaluatorManager(EvaluatorBase):
|
|||||||
q.join()
|
q.join()
|
||||||
|
|
||||||
def stop_all_workers(self):
|
def stop_all_workers(self):
|
||||||
self._notify_and_wait(None)
|
self._notify_and_wait(POISON_PILL)
|
||||||
|
for q in self._worker_queues:
|
||||||
|
q.close()
|
||||||
self._worker_queues = list()
|
self._worker_queues = list()
|
||||||
|
|
||||||
def reload_all_workers(self, enabled=True):
|
def reload_all_workers(self, enabled=True):
|
||||||
@ -126,20 +129,17 @@ class EvaluatorWorker(os_service.Service):
|
|||||||
|
|
||||||
def _read_queue(self):
|
def _read_queue(self):
|
||||||
while True:
|
while True:
|
||||||
try:
|
next_task = self._task_queue.get()
|
||||||
next_task = self._task_queue.get()
|
if next_task is POISON_PILL:
|
||||||
if next_task is None:
|
|
||||||
self._task_queue.task_done()
|
|
||||||
break # poison pill
|
|
||||||
self._do_task(next_task)
|
|
||||||
self._task_queue.task_done()
|
self._task_queue.task_done()
|
||||||
# Evaluator queue may have been updated, thus the sleep:
|
break
|
||||||
time.sleep(0)
|
try:
|
||||||
|
self._do_task(next_task)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# TODO(ihefetz): an exception here may break all the
|
LOG.exception("Graph may not be in sync: exception %s", e)
|
||||||
# TODO(ihefetz): evaluators. If task_done was not called,
|
self._task_queue.task_done()
|
||||||
# TODO(ihefetz): evaluator manager will wait forever.
|
# Evaluator queue may have been updated, thus the sleep:
|
||||||
LOG.exception("Exception: %s", e)
|
time.sleep(0)
|
||||||
|
|
||||||
def _do_task(self, task):
|
def _do_task(self, task):
|
||||||
(before, current, is_vertex, action) = task
|
(before, current, is_vertex, action) = task
|
||||||
|
@ -59,7 +59,6 @@ class GraphAlgorithm(object):
|
|||||||
|
|
||||||
In sub-graph matching algorithms complexity is high in the general case
|
In sub-graph matching algorithms complexity is high in the general case
|
||||||
Here it is considerably mitigated as we have an anchor in the graph.
|
Here it is considerably mitigated as we have an anchor in the graph.
|
||||||
TODO(ihefetz) document this
|
|
||||||
|
|
||||||
:type known_mappings: list
|
:type known_mappings: list
|
||||||
:type sub_graph: driver.Graph
|
:type sub_graph: driver.Graph
|
||||||
|
@ -58,7 +58,7 @@ class Connection(base.Connection):
|
|||||||
engine = self._engine_facade.get_engine()
|
engine = self._engine_facade.get_engine()
|
||||||
engine.connect()
|
engine.connect()
|
||||||
models.Base.metadata.create_all(engine, checkfirst=False)
|
models.Base.metadata.create_all(engine, checkfirst=False)
|
||||||
# TODO(ihefetz) upgrade logic is missing
|
# TODO(idan_hefetz) upgrade logic is missing
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
self._engine_facade.get_engine().dispose()
|
self._engine_facade.get_engine().dispose()
|
||||||
|
Loading…
Reference in New Issue
Block a user