From 302578a6c2c53cc0f814988f39ae114666edbaa7 Mon Sep 17 00:00:00 2001
From: Filippo Cremonese <filippocremonese@rev.ng>
Date: Tue, 15 Sep 2020 11:24:04 +0200
Subject: [PATCH] Raise exception if errors occur

---
 orchestra/executor.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/orchestra/executor.py b/orchestra/executor.py
index 8e7a7b1..49d7aab 100644
--- a/orchestra/executor.py
+++ b/orchestra/executor.py
@@ -1,7 +1,8 @@
 from concurrent import futures
-from loguru import logger
 from typing import List
 
+from loguru import logger
+
 from .actions.action import Action
 
 
@@ -12,6 +13,7 @@ class Executor:
         self._pending_actions = set()
         self._running_actions: List[futures.Future] = []
         self._pool = futures.ThreadPoolExecutor(max_workers=threads, thread_name_prefix="Builder")
+        self._errors_occurred = []
 
     def run(self, action, force=False):
         self._collect_actions(action, force=force)
@@ -29,9 +31,13 @@ class Executor:
                     if self._pending_actions:
                         logger.error(f"Waiting for other running actions to terminate: {self._pending_actions}")
                     self._pending_actions = set()
+                    self._errors_occurred.append(exception)
                 else:
                     self._schedule_next()
 
+        if self._errors_occurred:
+            raise Exception("Errors occurred", self._errors_occurred)
+
     def _collect_actions(self, action: Action, force=False):
         if not force and action.is_satisfied(recursively=True):
             return
-- 
GitLab