diff --git a/src/daemon/server.py b/src/daemon/server.py index 1ec8bf349b..26bb704de6 100644 --- a/src/daemon/server.py +++ b/src/daemon/server.py @@ -66,6 +66,7 @@ class PlotState(str, Enum): SUBMITTED = "SUBMITTED" RUNNING = "RUNNING" ERROR = "ERROR" + DELETED = "DELETED" FINISHED = "FINISHED" @@ -355,13 +356,16 @@ class WebSocketServer: while True: new = await loop.run_in_executor(io_pool_exc, fp.readline) + if config["state"] is not PlotState.RUNNING: + return + config["log"] = new if config["log"] is None else config["log"] + new self.state_changed(service_plotter, "log_changed") if new: for word in words: if word in new: - yield (word, new) + return else: time.sleep(0.5) @@ -371,8 +375,7 @@ class WebSocketServer: if config is None: raise Exception(f"Plot queue config with ID {id} is not defined") - async for hit_word, hit_sentence in self._watch_file_changes(id, loop): - break + await self._watch_file_changes(id, loop) def _build_plotting_command_args(self, request: Any, ignoreCount: bool) -> List[str]: service_name = request["service"] @@ -455,6 +458,9 @@ class WebSocketServer: delay = config["delay"] await asyncio.sleep(delay) + if config["state"] is PlotState.DELETED: + return + service_name = config["service_name"] command_args = config["command_args"] self.log.debug(f"command_args before launch_plotter are {command_args}") @@ -549,6 +555,9 @@ class WebSocketServer: process = config["process"] queue = config["queue"] + # mark plot config as deleted for already running asyncio functions + config["state"] = PlotState.DELETED + try: run_next = False if process is not None and state == PlotState.RUNNING: