BackgroundTaskRunner: automatically create a queue if necessary
Requiring all users to go create a queue themselves is extra boilerplate,
and rarely desired. Instead, have the context manager yield the queue,
and have it generate an instance if the passed in value was None.
BUG=None
TEST=unittests updated.
Change-Id: I9071227c5254e1b6b8e4da7ed52c21f51a83aaad
Reviewed-on: https://gerrit.chromium.org/gerrit/39387
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 321975b..9964dfd 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -403,9 +403,8 @@
# Set up a process pool to run test/archive stages in the background.
# This process runs task(board) for each board added to the queue.
- queue = multiprocessing.Queue()
task = self._RunBackgroundStagesForBoard
- with parallel.BackgroundTaskRunner(queue, task):
+ with parallel.BackgroundTaskRunner(task) as queue:
for board in self.build_config['boards']:
# Run BuildTarget in the foreground.
archive_stage = self.archive_stages[board]