MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / other_service_pids

Method other_service_pids

mod/project/python/serviceMod.py:633–660  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

631 return "停止指令已执行"
632
633 def other_service_pids(self) -> Set[int]:
634 res_pid = []
635 for i in self.other_services:
636 service = self._build_service_by_conf(i)
637 if isinstance(service, str):
638 continue
639 pid = service.get_service_pid()
640 if isinstance(pid, int) and pid > 0 and psutil.pid_exists(pid):
641 res_pid.append(pid)
642
643 sub_pid = []
644
645 def get_sub_pid(pro: psutil.Process) -> List[int]:
646 tmp_res = []
647 if pro.status() != psutil.STATUS_ZOMBIE and pro.children():
648 for sub_pro in pro.children():
649 tmp_res.append(sub_pro.pid)
650 tmp_res.extend(get_sub_pid(sub_pro))
651 return tmp_res
652
653 for i in res_pid:
654 try:
655 p = psutil.Process(i)
656 sub_pid.extend(get_sub_pid(p))
657 except:
658 pass
659
660 return set(res_pid + sub_pid)
661
662
663class main:

Callers 1

other_service_pidsMethod · 0.95

Calls 5

setFunction · 0.50
get_service_pidMethod · 0.45
pid_existsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected