| |
@@ -24,6 +24,7 @@
|
| |
def __init__(self, compose):
|
| |
self.compose = compose
|
| |
self.msg = "---------- PHASE: %s ----------" % self.name.upper()
|
| |
+ self.started = False
|
| |
self.finished = False
|
| |
self._skipped = False
|
| |
|
| |
@@ -55,6 +56,7 @@
|
| |
return False
|
| |
|
| |
def start(self):
|
| |
+ self.started = True
|
| |
self._skipped = self.skip()
|
| |
if self._skipped:
|
| |
self.compose.log_warning("[SKIP ] %s" % self.msg)
|
| |
@@ -104,21 +106,26 @@
|
| |
"Note that variants can be excluded in configuration file"
|
| |
)
|
| |
|
| |
- def stop(self):
|
| |
- if self.finished:
|
| |
+ def stop(self, kill=False):
|
| |
+ if self.finished or not self.started:
|
| |
return
|
| |
if hasattr(self, "pool"):
|
| |
+ if kill:
|
| |
+ self.pool.kill()
|
| |
self.pool.stop()
|
| |
self.finished = True
|
| |
- self.compose.log_info("[DONE ] %s" % self.msg)
|
| |
+ if kill:
|
| |
+ self.compose.log_info("[KILLED ] %s" % self.msg)
|
| |
+ else:
|
| |
+ self.compose.log_info("[DONE ] %s" % self.msg)
|
| |
|
| |
- if hasattr(self, "_start_time"):
|
| |
+ if hasattr(self, "_start_time") and not kill:
|
| |
self.compose.log_info(
|
| |
"PHASE %s took %d seconds"
|
| |
% (self.name.upper(), math.ceil(time.time() - self._start_time))
|
| |
)
|
| |
|
| |
- if self.used_patterns is not None:
|
| |
+ if self.used_patterns is not None and not kill:
|
| |
# We only want to report this if the config was actually queried.
|
| |
self.report_unused_patterns()
|
| |
self.compose.notifier.send("phase-stop", phase_name=self.name)
|
| |
Add a global list of PHASES, and if we wind up in sigterm_handler
or the except block of cli_main, call stop on every non-skipped
phase, to ensure we can exit.
To avoid actually running through stop() on phases that were
never started, add a started attribute to phases that's set on
start, and exit stop() early if it's not True.
Signed-off-by: Adam Williamson awilliam@redhat.com