Commit 2c035435 authored by Guido Trotter's avatar Guido Trotter
Browse files

burnin.ExecOrQueue: add post-process function

If a post-process function is passed to ExecOrQueue it is executed if
and only if the job is successful. This happens immediately if we're
proceding iteratively, and at the end, when we collect all job results,
if we're proceding in parallel.
Signed-off-by: default avatarGuido Trotter <>
Reviewed-by: default avatarIustin Pop <>
parent b05f29a6
...@@ -347,13 +347,16 @@ class Burner(object): ...@@ -347,13 +347,16 @@ class Burner(object):
self._SetDebug(ops) self._SetDebug(ops)
return self.MaybeRetry(rval, "opcode", self._ExecOp, *ops) return self.MaybeRetry(rval, "opcode", self._ExecOp, *ops)
def ExecOrQueue(self, name, ops): def ExecOrQueue(self, name, ops, post_process=None):
"""Execute an opcode and manage the exec buffer.""" """Execute an opcode and manage the exec buffer."""
if self.opts.parallel: if self.opts.parallel:
self._SetDebug(ops) self._SetDebug(ops)
self.queued_ops.append((ops, name)) self.queued_ops.append((ops, name, post_process))
else: else:
return self.ExecOp(self.queue_retry, *ops) # pylint: disable-msg=W0142 val = self.ExecOp(self.queue_retry, *ops) # pylint: disable-msg=W0142
if post_process is not None:
return val
def StartBatch(self, retry): def StartBatch(self, retry):
"""Start a new batch of jobs. """Start a new batch of jobs.
...@@ -391,7 +394,7 @@ class Burner(object): ...@@ -391,7 +394,7 @@ class Burner(object):
""" """
self.ClearFeedbackBuf() self.ClearFeedbackBuf()
jex = cli.JobExecutor(, feedback_fn=self.Feedback) jex = cli.JobExecutor(, feedback_fn=self.Feedback)
for ops, name in jobs: for ops, name, _ in jobs:
jex.QueueJob(name, *ops) # pylint: disable-msg=W0142 jex.QueueJob(name, *ops) # pylint: disable-msg=W0142
try: try:
results = jex.GetResults() results = jex.GetResults()
...@@ -399,10 +402,24 @@ class Burner(object): ...@@ -399,10 +402,24 @@ class Burner(object):
Log("Jobs failed: %s", err) Log("Jobs failed: %s", err)
raise BurninFailure() raise BurninFailure()
if utils.any(results, lambda x: not x[0]): fail = False
val = []
for (_, name, post_process), (success, result) in zip(jobs, results):
if success:
if post_process:
except Exception, err: # pylint: disable-msg=W0703
Log("Post process call for job %s failed: %s", name, err)
fail = True
fail = True
if fail:
raise BurninFailure() raise BurninFailure()
return [i[1] for i in results] return val
def ParseOptions(self): def ParseOptions(self):
"""Parses the command line options. """Parses the command line options.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment