MCPcopy
hub / github.com/ModelTC/LightLLM / terminate_all_processes

Method terminate_all_processes

lightllm/utils/start_utils.py:43–69  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

41 return
42
43 def terminate_all_processes(self):
44 from lightllm.utils.envs_utils import get_env_start_args
45
46 def kill_recursive(proc):
47 try:
48 parent = psutil.Process(proc.pid)
49 children = parent.children(recursive=True)
50 for child in children:
51 logger.info(f"Killing child process {child.pid}")
52 child.kill()
53 logger.info(f"Killing parent process {proc.pid}")
54 parent.kill()
55 except psutil.NoSuchProcess:
56 logger.warning(f"Process {proc.pid} does not exist.")
57
58 for proc in self.processes:
59 if proc.is_alive():
60 kill_recursive(proc)
61 proc.join()
62
63 # recover the gpu compute mode
64 is_enable_mps = get_env_start_args().enable_mps
65 if is_enable_mps:
66 from lightllm.utils.device_utils import stop_mps
67
68 stop_mps()
69 logger.info("All processes terminated gracefully.")
70
71
72def start_submodule_processes(start_funcs=[], start_args=[]):

Callers 1

signal_handlerFunction · 0.80

Calls 3

get_env_start_argsFunction · 0.90
stop_mpsFunction · 0.90
kill_recursiveFunction · 0.85

Tested by

no test coverage detected