Check result of run_installer
@@ -285,7 +285,9 @@ class Cli:
except ArchiveDownloadError or ArchiveListError or NoPackageFound:
exit(1)
target_config = qt_archives.get_target_config()
- run_installer(qt_archives.get_packages(), base_dir, sevenzip, keep)
+ result = run_installer(qt_archives.get_packages(), base_dir, sevenzip, keep)
+ if not result:
+ exit(1)
if not nopatch:
Updater.update(target_config, base_dir)
self.logger.info("Finished installation")
@@ -363,8 +365,11 @@ class Cli:
exit(1)
except ArchiveDownloadError or ArchiveListError:
exit(1)
- run_installer(srcdocexamples_archives.get_packages(), base_dir, sevenzip, keep)
+ result = run_installer(srcdocexamples_archives.get_packages(), base_dir, sevenzip, keep)
+ if result:
self.logger.info("Finished installation")
+ else:
+ exit(1)
def run_src(self, args):
"""Run src subcommand"""
@@ -466,7 +471,9 @@ class Cli:
exit(1)
except ArchiveDownloadError or ArchiveListError:
exit(1)
- run_installer(tool_archives.get_packages(), base_dir, sevenzip, keep)
+ result = run_installer(tool_archives.get_packages(), base_dir, sevenzip, keep)
+ if not result:
+ exit(1)
self.logger.info("Finished installation")
self.logger.info(
"Time elapsed: {time:.8f} second".format(
@@ -819,7 +826,8 @@ class Cli:
def run_installer(
archives: List[QtPackage], base_dir: str, sevenzip: Optional[str], keep: bool
-):
+) -> bool:
+ result = True
queue = multiprocessing.Manager().Queue(-1)
listener = MyQueueListener(queue)
listener.start()
@@ -827,23 +835,26 @@ def run_installer(
tasks = []
for arc in archives:
tasks.append((arc, base_dir, sevenzip, queue, keep))
- original_sh = signal.signal(signal.SIGINT, signal.SIG_IGN)
ctx = multiprocessing.get_context("spawn")
- pool = ctx.Pool(Settings.concurrency)
- signal.signal(signal.SIGINT, original_sh)
+ pool = ctx.Pool(Settings.concurrency, init_worker_sh)
try:
pool.starmap(installer, tasks)
- #
pool.close()
+ pool.join()
except KeyboardInterrupt:
+ logger= getLogger("aqt.installer")
+ logger.warning("Caught KeyboardInterrupt, terminating installer workers")
pool.terminate()
- else:
- pool.close()
pool.join()
+ result = False
# all done, close logging service for sub-processes
listener.enqueue_sentinel()
listener.stop()
+ return result
+
+def init_worker_sh():
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
def installer(
qt_archive: QtPackage,
