Merge "Eliminate unnecessary sleeps during no-op update"

This commit is contained in:
Jenkins 2015-12-08 15:21:32 +00:00 committed by Gerrit Code Review
commit 21bc5f9b76
2 changed files with 7 additions and 4 deletions

View File

@ -351,7 +351,8 @@ class DependencyTaskGroup(object):
of the error will be cancelled). Once all chains are complete, any
errors will be rolled up into an ExceptionGroup exception.
"""
self._runners = dict((o, TaskRunner(task, o)) for o in dependencies)
self._keys = list(dependencies)
self._runners = dict((o, TaskRunner(task, o)) for o in self._keys)
self._graph = dependencies.graph(reverse=reverse)
self.error_wait_time = error_wait_time
self.aggregate_exceptions = aggregate_exceptions
@ -374,6 +375,8 @@ class DependencyTaskGroup(object):
try:
for k, r in self._ready():
r.start()
if not r:
del self._graph[k]
yield
@ -417,8 +420,8 @@ class DependencyTaskGroup(object):
Ready subtasks are subtasks whose dependencies have all been satisfied,
but which have not yet been started.
"""
for k, n in six.iteritems(self._graph):
if not n:
for k in self._keys:
if not self._graph.get(k, True):
runner = self._runners[k]
if runner and not runner.started():
yield k, runner

View File

@ -94,7 +94,7 @@ class DependencyTaskGroupTest(common.HeatTestCase):
self.steps = 0
self.m.StubOutWithMock(scheduler.TaskRunner, '_sleep')
with self._dep_test(('second', 'first')):
scheduler.TaskRunner._sleep(None).AndReturn(None)
pass
def test_single_node(self):
with self._dep_test(('only', None)) as dummy: