MCPcopy Create free account
hub / github.com/1jehuang/jcode / iter_jcode_processes

Function iter_jcode_processes

scripts/jcode_memory_snapshot.py:158–184  ·  view source on GitHub ↗
(main_socket: str, include_aux: bool)

Source from the content-addressed store, hash-verified

156
157
158def iter_jcode_processes(main_socket: str, include_aux: bool) -> Iterable[ProcMem]:
159 for pid_dir in Path("/proc").iterdir():
160 if not pid_dir.name.isdigit():
161 continue
162 pid = int(pid_dir.name)
163 argv = read_argv(pid_dir / "cmdline")
164 if not argv:
165 continue
166 cmd = " ".join(argv)
167 if "jcode" not in cmd:
168 continue
169 role, is_main = classify_process(argv, cmd, main_socket)
170 if role is None:
171 continue
172 if not include_aux and not is_main and role not in {"server"}:
173 continue
174 smaps = parse_smaps_rollup(pid)
175 if not smaps:
176 continue
177 yield ProcMem(
178 pid=pid,
179 role=role,
180 cmd=cmd,
181 session_id=parse_session_id(cmd),
182 socket_path=parse_socket_path(cmd),
183 **smaps,
184 )
185
186
187def sum_totals(procs: list[ProcMem]) -> Totals:

Callers 1

mainFunction · 0.85

Calls 7

PathClass · 0.85
read_argvFunction · 0.85
classify_processFunction · 0.85
parse_smaps_rollupFunction · 0.85
ProcMemClass · 0.85
parse_session_idFunction · 0.85
parse_socket_pathFunction · 0.85

Tested by

no test coverage detected