From 040dd57ad06d614a56ae4b41d07939dadc1bf026 Mon Sep 17 00:00:00 2001 From: Michael Zimmermann Date: Wed, 11 Aug 2021 10:44:12 +0200 Subject: [PATCH] project: print logs from the correct job `enumerate` on `imap_unordered` does (obviously) not return the index of the element that finished processing. That resulted in printing the wrong log file which might not even be finished and thus swallowing future logs of that job. Instead, let each job return it's index. Fixes: #528 Signed-off-by: Michael Zimmermann --- src/west/app/project.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/west/app/project.py b/src/west/app/project.py index 679e224..9b6d52c 100644 --- a/src/west/app/project.py +++ b/src/west/app/project.py @@ -858,7 +858,7 @@ class Update(_ProjectCommand): @staticmethod def _update_concurrent_thread(args): - project, self, logdir = args + index, project, self, logdir = args if logdir: saved_stdout = os.dup(sys.stdout.fileno()) saved_stderr = os.dup(sys.stderr.fileno()) @@ -872,9 +872,9 @@ class Update(_ProjectCommand): try: self.update(project) - return True + return (index, True) except subprocess.CalledProcessError: - return False + return (index, False) finally: if logdir: sys.stdout.flush() @@ -902,13 +902,12 @@ class Update(_ProjectCommand): log.dbg(f"log directory: {logdir_name}") args = [] - for project in projects: - args.append((project, self, logdir_name)) + for index, project in enumerate(projects): + args.append((index, project, self, logdir_name)) with multiprocessing.Pool(self.args.jobs) as p: - for index, successful in enumerate( - p.imap_unordered(self._update_concurrent_thread, - args)): + for index, successful in p.imap_unordered( + self._update_concurrent_thread, args): project = projects[index] if logdir: