From a85c947f15f6eeb12e9cbba3d13719953dabc21a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Sat, 31 Oct 2020 01:34:36 +0100 Subject: [PATCH] cleaning up finished --- core/tmtc_backend.py | 6 ++++-- core/tmtc_client_core.py | 20 +++++++------------- core/tmtc_frontend.py | 4 ++-- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/core/tmtc_backend.py b/core/tmtc_backend.py index 22aed03..7f06ebc 100644 --- a/core/tmtc_backend.py +++ b/core/tmtc_backend.py @@ -2,6 +2,7 @@ import atexit import time import logging import sys +from multiprocessing import Process from collections import deque from config import obsw_config as g from typing import Tuple, Union @@ -48,8 +49,9 @@ class TmTcHandler: LOGGER.info("TM listener will not be started") atexit.register(keyboard_interrupt_handler, com_interface=self.communication_interface) - def start(self): - self.perform_operation() + def prepare_start(self) -> Process: + handler_process = Process(target=self.perform_operation()) + return handler_process def perform_operation(self): """ diff --git a/core/tmtc_client_core.py b/core/tmtc_client_core.py index a3ce3bc..b7fc889 100755 --- a/core/tmtc_client_core.py +++ b/core/tmtc_client_core.py @@ -26,8 +26,6 @@ limitations under the License. @manual Run this file with the -h flag to display options. """ -from multiprocessing import Process - from tmtc_core.utility.obsw_logger import set_tmtc_logger, get_logger from config.obsw_config import set_globals @@ -53,19 +51,15 @@ def run_tmtc_client(use_gui: bool): LOGGER.info("Starting TMTC Handler") tmtc_handler = TmTcHandler() + tmtc_handler_task = tmtc_handler.prepare_start() + tmtc_frontend = TmTcFrontend(tmtc_handler) + tmtc_frontend_task = tmtc_frontend.prepare_start() - if use_gui: - start_with_gui(tmtc_handler) - else: - tmtc_handler.start() - + tmtc_handler_task.start() + tmtc_frontend_task.start() -def start_with_gui(tmtc_handler: TmTcHandler): - LOGGER.info("Starting TMTC GUI") - tmtc_frontend = TmTcFrontend(tmtc_handler) - frontend_process = Process(target=tmtc_frontend.init_ui()) - frontend_process.start() - tmtc_handler.start() + tmtc_handler_task.join() + tmtc_frontend_task.join() diff --git a/core/tmtc_frontend.py b/core/tmtc_frontend.py index 098f358..796ee5d 100644 --- a/core/tmtc_frontend.py +++ b/core/tmtc_frontend.py @@ -58,8 +58,8 @@ class TmTcFrontend: obsw_config.G_SERVICE = 17 obsw_config.G_COM_IF = obsw_config.ComIF.QEMU - def start(self): - self.init_ui() + def prepare_start(self) -> Process: + return Process(target=self.init_ui()) def service_index_changed(self, index: int): obsw_config.G_SERVICE = self.serviceList[index] -- GitLab