Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: recipe_engine/run.py

Issue 2245113002: Track step nesting in StreamEngine. (Closed) Base URL: https://github.com/luci/recipes-py@emit-initial-properties
Patch Set: Iterate Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | recipe_engine/simulation_test.py » ('j') | recipe_engine/stream.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/run.py
diff --git a/recipe_engine/run.py b/recipe_engine/run.py
index 17b8890053c65d2ba19bda1dc8ce5adac8914e05..96e871229a6ac62c1d5e948d01dbca184269e980 100644
--- a/recipe_engine/run.py
+++ b/recipe_engine/run.py
@@ -296,8 +296,8 @@ class RecipeEngine(object):
* step - uses engine.create_step(...), and previous_step_result.
"""
- ActiveStep = collections.namedtuple('ActiveStep',
- 'step step_result open_step nest_level')
+ ActiveStep = collections.namedtuple('ActiveStep', (
+ 'step', 'step_result', 'open_step', 'nest_level'))
def __init__(self, step_runner, properties, universe_view):
"""See run_steps() for parameter meanings."""
@@ -343,9 +343,13 @@ class RecipeEngine(object):
" with try-finally blocks.")
return self._step_stack[-1].step_result
- def _close_to_level(self, level):
- """Close all open steps that are at least as deep as level."""
- while self._step_stack and level <= self._step_stack[-1].nest_level:
+ def _close_through_level(self, level):
+ """Close all open steps whose nest level is >= the supplied level.
+
+ Args:
+ level (int): the nest level to close through.
+ """
+ while self._step_stack and self._step_stack[-1].nest_level >= level:
cur = self._step_stack.pop()
if cur.step_result:
cur.step_result.presentation.finalize(cur.open_step.stream)
@@ -368,8 +372,8 @@ class RecipeEngine(object):
step_result = None
- nest_level = step.pop('step_nest_level', 0)
- self._close_to_level(nest_level)
+ nest_level = step.get('nest_level', 0)
+ self._close_through_level(nest_level)
open_step = self._step_runner.open_step(step)
self._step_stack.append(self.ActiveStep(
@@ -377,8 +381,6 @@ class RecipeEngine(object):
step_result=None,
open_step=open_step,
nest_level=nest_level))
- if nest_level:
- open_step.stream.set_nest_level(nest_level)
step_result = open_step.run()
self._step_stack[-1] = (
@@ -428,7 +430,7 @@ class RecipeEngine(object):
"status_code": 0
}
finally:
- self._close_to_level(0)
+ self._close_through_level(0)
except recipe_api.StepFailure as f:
result = {
# Include "recipe_result" so it doesn't get marked as infra failure.
« no previous file with comments | « no previous file | recipe_engine/simulation_test.py » ('j') | recipe_engine/stream.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698