From b239eb58ab47363496ad490f943d5bd40d59fc85 Mon Sep 17 00:00:00 2001 From: tazlin Date: Wed, 4 Oct 2023 10:46:54 -0400 Subject: [PATCH] fix: exit from subprocess on fail/end --- horde_worker_regen/process_management/horde_process.py | 2 ++ horde_worker_regen/process_management/inference_process.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/horde_worker_regen/process_management/horde_process.py b/horde_worker_regen/process_management/horde_process.py index 31743bf0..cbe0a61d 100644 --- a/horde_worker_regen/process_management/horde_process.py +++ b/horde_worker_regen/process_management/horde_process.py @@ -3,6 +3,7 @@ import abc import enum import signal +import sys import time from abc import abstractmethod from enum import auto @@ -207,6 +208,7 @@ def main_loop(self) -> None: process_state=HordeProcessState.PROCESS_ENDED, info="Process ended", ) + sys.exit(1) def signal_handler(sig: int, frame: object) -> None: diff --git a/horde_worker_regen/process_management/inference_process.py b/horde_worker_regen/process_management/inference_process.py index cc80fe4e..1daa1343 100644 --- a/horde_worker_regen/process_management/inference_process.py +++ b/horde_worker_regen/process_management/inference_process.py @@ -4,6 +4,7 @@ import contextlib import enum import io +import sys import time from enum import auto @@ -95,11 +96,13 @@ def __init__( self._shared_model_manager = SharedModelManager() except Exception as e: logger.critical(f"Failed to initialise HordeLib: {type(e).__name__} {e}") + sys.exit(1) try: self._checkpoint_loader = HordeCheckpointLoader() except Exception as e: logger.critical(f"Failed to initialise HordeCheckpointLoader: {type(e).__name__} {e}") + sys.exit(1) if SharedModelManager.manager.compvis is None: logger.critical("Failed to initialise SharedModelManager") @@ -107,7 +110,7 @@ def __init__( process_state=HordeProcessState.PROCESS_ENDED, info="Failed to initialise compvis in SharedModelManager", ) - return + sys.exit(1) if len(SharedModelManager.manager.compvis.available_models) == 0: logger.critical("No models available in SharedModelManager") @@ -115,7 +118,7 @@ def __init__( process_state=HordeProcessState.PROCESS_ENDED, info="No models available in SharedModelManager", ) - return + sys.exit(1) logger.info("HordeInferenceProcess initialised")