Commit 3cd5358eedbe386f9f7ea3fbee2fdf9ff2985a2e

Authored by Alexis Koralewski
1 parent e9e49c7a
Exists in dev

fixing sigINT on pyros new-start

Showing 1 changed file with 20 additions and 33 deletions   Show diff stats
pyros.py
... ... @@ -1124,8 +1124,9 @@ def new_start(configfile: str, observatory: str, unit: str, computer_hostname: s
1124 1124 # if not test_mode(): current_processes.append( [execProcessFromVenvAsync(cmd), agent_name, -1] )
1125 1125 # Append this process ( [process id, agent_name, result=failure] )
1126 1126 # ("result" will be updated at the end of execution)
1127   - current_processes.append(
1128   - [execProcessFromVenvAsync(cmd,foreground), agent_name, -1])
  1127 +
  1128 + process = execProcessFromVenvAsync(cmd,foreground)
  1129 +
1129 1130 # self.change_dir("..")
1130 1131 os.chdir(current_dir)
1131 1132  
... ... @@ -1134,38 +1135,24 @@ def new_start(configfile: str, observatory: str, unit: str, computer_hostname: s
1134 1135 # os.chdir("..")
1135 1136 # Wait for end of each process execution
1136 1137 # for (p,agent) in current_processes:
1137   - for process in current_processes:
1138   - p, agent, _ = process
1139   - log.debug(
1140   - f"************ Waiting for end of execution of agent {agent} ************")
1141   - p.wait()
1142   - process[2] = p.returncode
1143   - print(f"************ END of execution of agent {agent} ************")
1144   - if p.returncode == 0:
1145   - printFullTerm(
1146   - Colors.GREEN, f"Process {agent} executed successfully")
1147   - # self.addExecuted(self.current_command, command)
1148   - else:
1149   - printFullTerm(Colors.WARNING, f"Process {agent} execution failed")
1150   - # self.addError(self.current_command, command)
1151   -
1152   - print()
1153   - print()
1154   - print("Synthesis of the results:")
1155   - for process in current_processes:
1156   - p, agent, returncode = process
1157   - if returncode == 0:
1158   - printFullTerm(
1159   - Colors.GREEN, f"Process {agent} executed successfully")
1160   - # self.addExecuted(self.current_command, command)
1161   - else:
1162   - printFullTerm(Colors.WARNING, f"Process {agent} execution failed")
1163   - # self.addError(self.current_command, command)
  1138 + agent = agent_name
  1139 + log.debug(
  1140 + f"************ Waiting for end of execution of agent {agent} ************")
  1141 + try:
  1142 + process.wait()
  1143 + except KeyboardInterrupt:
  1144 + process.send_signal(signal.SIGINT)
  1145 + process.wait()
  1146 + print(f"************ END of execution of agent {agent} ************")
  1147 + if process.returncode == 0:
  1148 + printFullTerm(
  1149 + Colors.GREEN, f"Process {agent} executed successfully")
  1150 + # self.addExecuted(self.current_command, command)
  1151 + else:
  1152 + printFullTerm(Colors.WARNING, f"Process {agent} execution failed")
  1153 + # self.addError(self.current_command, command)
1164 1154  
1165   - # print("************ end of START() ************")
1166   - # Only according to the last process status:
1167   - # return True if p.returncode==0 else False
1168   - return True if p.returncode == 0 else False
  1155 + return True if process.returncode == 0 else False
1169 1156  
1170 1157 @pyros_launcher.command(help="Stop pyros")
1171 1158 def stop():
... ...