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):
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."""
if self.opts.parallel:
self.queued_ops.append((ops, name))
self.queued_ops.append((ops, name, post_process))
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):
"""Start a new batch of jobs.
......@@ -391,7 +394,7 @@ class Burner(object):
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
results = jex.GetResults()
......@@ -399,10 +402,24 @@ class Burner(object):
Log("Jobs failed: %s", err)
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()
return [i[1] for i in results]
return val
def ParseOptions(self):
"""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