diff --git a/src/core/pyros_django/agent/AgentSST.py b/src/core/pyros_django/agent/AgentSST.py index 7d8bd9e..9ec2299 100644 --- a/src/core/pyros_django/agent/AgentSST.py +++ b/src/core/pyros_django/agent/AgentSST.py @@ -25,8 +25,8 @@ class AgentSST(Agent): subprocess_dict = {} AGENT_SPECIFIC_COMMANDS = [ - "kill_agent", - "restart_agent" + "do_kill_agent", + "do_restart_agent" ] def __init__(self, name:str=None,sim_computer=None): @@ -87,6 +87,7 @@ class AgentSST(Agent): cmd = self.VENV_PYTHON +" "+ protocol_folder_abs_path + os.sep + protocol_script_name process = subprocess.Popen(f"{cmd}", shell=True, stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT) + process.poll() self.subprocess_dict[agent] = process log.info(f"Start agent {agent} with cmd {cmd}") @@ -117,15 +118,15 @@ class AgentSST(Agent): self.start_agents(agent_name) - def kill_agent(self, *args)->None: + def do_kill_agent(self, *args)->None: agent = args[0] if agent in self.subprocess_dict.keys(): cmd = self.send_cmd_to(agent,"do_exit") return cmd - def restart_agent(self, *args)->None: + def do_restart_agent(self, *args)->None: agent = args[0] - self.kill_agent(agent) + self.do_kill_agent(agent) self.start_agent(agent) # if agent in self.subprocess_dict.keys(): # cmd.set_result(f"Agent {agent} restarted") @@ -149,7 +150,7 @@ class AgentSST(Agent): def do_things_before_exit(self,abort_cmd_sender): kill_agent_commands = {} for agent in self.subprocess_dict.keys(): - cmd = self.kill_agent(agent) + cmd = self.do_kill_agent(agent) kill_agent_commands[agent] = cmd # wait 10 seconds in order to agents to exit themselves properly time.sleep(10) @@ -158,7 +159,7 @@ class AgentSST(Agent): while self.subprocess_dict[agent].poll() is None: time.sleep(0.5) - def routine_process_before_body(self): + def routine_process_after(self): now_time = datetime.now(timezone.utc) last_running_commands = AgentCmd.get_commands_sent_by_agent("AgentSST").filter(state="CMD_RUNNING") -- libgit2 0.21.2