Always call TaskRunner._sleep()
In the patch5f584db8d5
, we avoid calling TaskRunner._sleep() after the first step if the wait_time is 0 or None. This is wrong in the case of a wait_time of 0 - since this is distinct from None, and should result in us calling eventlet.sleep(0). It's also inconsistent in the case of wait_time=None, since for the rest of the steps we call self._sleep(None) (and no actual sleep occurs). This patch ensures we always call self._sleep(), passing 0 or None as appropriate. It also enhances the change ind66d57f187
to ensure that we never yield from DependencyTaskGroup after all tasks are completed, which could happen if that last batch of tasks to be started all completed in a single step. This both saves changing the unit test to accomodate the new _sleep(None) call and avoids an unnecessary eventlet.sleep(0) call in real usage. Change-Id: I301930fcba170e36d2d902c8d693ca722476cd18
This commit is contained in:
parent
0951799e70
commit
1de87a9b36
|
@ -177,8 +177,8 @@ class TaskRunner(object):
|
|||
self.start(timeout=timeout)
|
||||
# ensure that zero second sleep is applied only if task
|
||||
# has not completed.
|
||||
if not self.done() and wait_time:
|
||||
self._sleep(0)
|
||||
if not self.done():
|
||||
self._sleep(0 if wait_time is not None else None)
|
||||
self.run_to_completion(wait_time=wait_time)
|
||||
|
||||
def start(self, timeout=None):
|
||||
|
@ -431,7 +431,8 @@ class DependencyTaskGroup(object):
|
|||
if not r:
|
||||
del self._graph[k]
|
||||
|
||||
yield
|
||||
if self._graph:
|
||||
yield
|
||||
|
||||
for k, r in self._running():
|
||||
if r.step():
|
||||
|
|
|
@ -854,7 +854,7 @@ class StackUpdateTest(common.HeatTestCase):
|
|||
tmpl2 = {'HeatTemplateFormatVersion': '2012-12-12',
|
||||
'Resources': {
|
||||
'AResource': {'Type': 'GenericResourceType'},
|
||||
'BResource': {'Type': 'GenericResourceType'}}}
|
||||
'BResource': {'Type': 'MultiStepResourceType'}}}
|
||||
updated_stack = stack.Stack(self.ctx, 'updated_stack',
|
||||
template.Template(tmpl2),
|
||||
disable_rollback=disable_rollback)
|
||||
|
|
Loading…
Reference in New Issue