@@ -718,54 +718,6 @@ def find_docker_console():
718718
719719 LogManager .logger .info ("Run application transition finished" )
720720
721- def terminate_harmonic_processes (self ):
722- """
723- Terminate all Harmonic processes in the container.
724-
725- Terminate all processes in the container
726- whose command line contains 'gz' or 'launch'.
727- """
728- LogManager .logger .info ("Terminate Harmonic process" )
729- keywords = ["gz" , "launch" ]
730- for keyword in keywords :
731- try :
732- ps_aux_cmd = ["ps" , "aux" ]
733- grep_cmd = ["grep" , keyword ]
734- grep_exclude_cmd = ["grep" , "-v" , "grep" ]
735-
736- ps_aux_proc = subprocess .Popen (ps_aux_cmd , stdout = subprocess .PIPE )
737- grep_proc = subprocess .Popen (
738- grep_cmd , stdin = ps_aux_proc .stdout , stdout = subprocess .PIPE
739- )
740- exclude_grep_proc = subprocess .Popen (
741- grep_exclude_cmd , stdin = grep_proc .stdout , stdout = subprocess .PIPE
742- )
743-
744- ps_aux_proc .stdout .close ()
745- grep_proc .stdout .close ()
746-
747- output = exclude_grep_proc .communicate ()[0 ].decode ("utf-8" )
748-
749- for line in output .splitlines ():
750- try :
751- # Extract PID
752- pid = int (line .split ()[1 ])
753- subprocess .run (["kill" , "-15" , str (pid )], check = True )
754-
755- # Avoid zombies
756- try :
757- os .waitpid (pid , 0 )
758- except ChildProcessError :
759- pass
760- except Exception as e :
761- LogManager .logger .exception (
762- f"Failed to terminate process with line: { line } . Error: { e } "
763- )
764-
765- except Exception as e :
766- LogManager .logger .exception (
767- f"Failed to search and terminate processes with keyword '{ keyword } ': { e } "
768- )
769721
770722 def on_terminate_application (self , event ):
771723 """
@@ -790,7 +742,6 @@ def on_terminate_application(self, event):
790742 def on_terminate_tools (self , event ):
791743
792744 self .tools_launcher .terminate ()
793- self .terminate_harmonic_processes ()
794745
795746 def on_terminate_universe (self , event ):
796747 """
@@ -806,7 +757,6 @@ def on_terminate_universe(self, event):
806757 self .world_launcher .terminate ()
807758 if self .robot_launcher is not None :
808759 self .robot_launcher .terminate ()
809- self .terminate_harmonic_processes ()
810760
811761 def on_disconnect (self , event ):
812762 """
@@ -846,8 +796,6 @@ def on_disconnect(self, event):
846796 except Exception as e :
847797 LogManager .logger .exception ("Exception terminating world launcher" )
848798
849- self .terminate_harmonic_processes ()
850-
851799 # Reiniciar el script
852800 python = sys .executable
853801 os .execl (python , python , * sys .argv )
@@ -970,7 +918,6 @@ def signal_handler(sign, frame):
970918 except Exception as e :
971919 LogManager .logger .exception ("Exception terminating world launcher" )
972920
973- self .terminate_harmonic_processes ()
974921 exit ()
975922
976923 signal .signal (signal .SIGINT , signal_handler )
0 commit comments