MCPcopy Create free account
hub / github.com/FastLED/FastLED / get_process_tree_info

Function get_process_tree_info

ci/util/test_env.py:43–69  ·  view source on GitHub ↗

Get information about a process and its children

(pid: int)

Source from the content-addressed store, hash-verified

41
42
43def get_process_tree_info(pid: int) -> str:
44 """Get information about a process and its children"""
45 import psutil # noqa: PLC0415 - lazy: ~21ms saved on normal execution paths
46
47 try:
48 process = psutil.Process(pid)
49 info = [f"Process {pid} ({process.name()})"]
50 info.append(f"Status: {process.status()}")
51 info.append(f"CPU Times: {process.cpu_times()}")
52 info.append(f"Memory: {process.memory_info()}")
53
54 # Get child processes
55 children = process.children(recursive=True)
56 if children:
57 info.append("\nChild processes:")
58 for child in children:
59 info.append(f" Child {child.pid} ({child.name()})")
60 info.append(f" Status: {child.status()}")
61 info.append(f" CPU Times: {child.cpu_times()}")
62 info.append(f" Memory: {child.memory_info()}")
63
64 return "\n".join(info)
65 except KeyboardInterrupt as ki:
66 handle_keyboard_interrupt(ki)
67 raise
68 except:
69 return f"Could not get process info for PID {pid}"
70
71
72def kill_process_tree(pid: int) -> None:

Callers 1

dump_thread_stacksFunction · 0.85

Calls 4

statusMethod · 0.80
nameMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected