job.parallel should accumulate any exceptions that are thrown during
its calls to fork_waitfor and then raise them in a single JobError
after all the tasks are complete.
Signed-off-by: John Admanski <jadmanski@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1161 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/job.py b/client/bin/job.py
index fa10b58..7fbf223 100755
--- a/client/bin/job.py
+++ b/client/bin/job.py
@@ -424,9 +424,13 @@
old_log_path = os.path.join(self.resultdir, old_log_filename)
old_log = open(old_log_path, "a")
+ exceptions = []
for i, pid in enumerate(pids):
# wait for the task to finish
- fork_waitfor(self.resultdir, pid)
+ try:
+ fork_waitfor(self.resultdir, pid)
+ except Exception, e:
+ exceptions.append(e)
# copy the logs from the subtask into the main log
new_log_path = old_log_path + (".%d" % i)
if os.path.exists(new_log_path):
@@ -439,6 +443,11 @@
self.log_filename = old_log_filename
+ # handle any exceptions raised by the parallel tasks
+ if exceptions:
+ msg = "%d task(s) failed" % len(exceptions)
+ raise JobError(msg, str(exceptions), exceptions)
+
def quit(self):
# XXX: should have a better name.