2 from contextlib import AbstractContextManager
3 from typing import Any, Callable, Iterable, Iterator, Tuple, TypeVar
8 CONN_CLOSE as CONN_CLOSE,
9 CONN_CLOSE_WAIT as CONN_CLOSE_WAIT,
10 CONN_CLOSING as CONN_CLOSING,
11 CONN_ESTABLISHED as CONN_ESTABLISHED,
12 CONN_FIN_WAIT1 as CONN_FIN_WAIT1,
13 CONN_FIN_WAIT2 as CONN_FIN_WAIT2,
14 CONN_LAST_ACK as CONN_LAST_ACK,
15 CONN_LISTEN as CONN_LISTEN,
16 CONN_NONE as CONN_NONE,
17 CONN_SYN_RECV as CONN_SYN_RECV,
18 CONN_SYN_SENT as CONN_SYN_SENT,
19 CONN_TIME_WAIT as CONN_TIME_WAIT,
24 NIC_DUPLEX_FULL as NIC_DUPLEX_FULL,
25 NIC_DUPLEX_HALF as NIC_DUPLEX_HALF,
26 NIC_DUPLEX_UNKNOWN as NIC_DUPLEX_UNKNOWN,
30 POWER_TIME_UNKNOWN as POWER_TIME_UNKNOWN,
31 POWER_TIME_UNLIMITED as POWER_TIME_UNLIMITED,
32 STATUS_DEAD as STATUS_DEAD,
33 STATUS_DISK_SLEEP as STATUS_DISK_SLEEP,
34 STATUS_IDLE as STATUS_IDLE,
35 STATUS_LOCKED as STATUS_LOCKED,
36 STATUS_PARKED as STATUS_PARKED,
37 STATUS_RUNNING as STATUS_RUNNING,
38 STATUS_SLEEPING as STATUS_SLEEPING,
39 STATUS_STOPPED as STATUS_STOPPED,
40 STATUS_TRACING_STOP as STATUS_TRACING_STOP,
41 STATUS_WAITING as STATUS_WAITING,
42 STATUS_WAKING as STATUS_WAKING,
43 STATUS_ZOMBIE as STATUS_ZOMBIE,
46 AccessDenied as AccessDenied,
48 NoSuchProcess as NoSuchProcess,
49 TimeoutExpired as TimeoutExpired,
50 ZombieProcess as ZombieProcess,
76 if sys.platform == "linux":
77 from ._pslinux import (
78 IOPRIO_CLASS_BE as IOPRIO_CLASS_BE,
79 IOPRIO_CLASS_IDLE as IOPRIO_CLASS_IDLE,
80 IOPRIO_CLASS_NONE as IOPRIO_CLASS_NONE,
81 IOPRIO_CLASS_RT as IOPRIO_CLASS_RT,
83 if sys.platform == "win32":
84 from ._psutil_windows import (
85 ABOVE_NORMAL_PRIORITY_CLASS as ABOVE_NORMAL_PRIORITY_CLASS,
86 BELOW_NORMAL_PRIORITY_CLASS as BELOW_NORMAL_PRIORITY_CLASS,
87 HIGH_PRIORITY_CLASS as HIGH_PRIORITY_CLASS,
88 IDLE_PRIORITY_CLASS as IDLE_PRIORITY_CLASS,
89 NORMAL_PRIORITY_CLASS as NORMAL_PRIORITY_CLASS,
90 REALTIME_PRIORITY_CLASS as REALTIME_PRIORITY_CLASS,
92 from ._pswindows import (
93 CONN_DELETE_TCB as CONN_DELETE_TCB,
94 IOPRIO_HIGH as IOPRIO_HIGH,
95 IOPRIO_LOW as IOPRIO_LOW,
96 IOPRIO_NORMAL as IOPRIO_NORMAL,
97 IOPRIO_VERYLOW as IOPRIO_VERYLOW,
98 win_service_get as win_service_get,
99 win_service_iter as win_service_iter,
102 if sys.platform == "linux":
103 from ._pslinux import pfullmem, pmem
104 elif sys.platform == "darwin":
105 from ._psosx import pfullmem, pmem
106 elif sys.platform == "win32":
107 from ._pswindows import pfullmem, pmem
112 if sys.platform == "linux":
115 version_info: tuple[int, int, int]
120 def __init__(self, pid: int | None = ...) -> None: ...
121 def __eq__(self, other: object) -> bool: ...
122 def __ne__(self, other: object) -> bool: ...
123 def __hash__(self) -> int: ...
125 def pid(self) -> int: ...
126 def oneshot(self) -> AbstractContextManager[None]: ...
128 self, attrs: list[str] | Tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ...
129 ) -> dict[str, Any]: ...
130 def parent(self) -> Process: ...
131 def parents(self) -> list[Process]: ...
132 def is_running(self) -> bool: ...
133 def ppid(self) -> int: ...
134 def name(self) -> str: ...
135 def exe(self) -> str: ...
136 def cmdline(self) -> list[str]: ...
137 def status(self) -> _Status: ...
138 def username(self) -> str: ...
139 def create_time(self) -> float: ...
140 def cwd(self) -> str: ...
141 def nice(self, value: int | None = ...) -> int: ...
142 if sys.platform != "win32":
143 def uids(self) -> puids: ...
144 def gids(self) -> pgids: ...
145 def terminal(self) -> str: ...
146 def num_fds(self) -> int: ...
147 if sys.platform != "darwin":
148 def io_counters(self): ...
149 def ionice(self, ioclass: int | None = ..., value: int | None = ...) -> pionice: ...
150 if sys.platform == "linux":
151 def rlimit(self, resource: int, limits: tuple[int, int] | None = ...) -> tuple[int, int]: ...
152 if sys.platform != "darwin":
153 def cpu_affinity(self, cpus: list[int] | None = ...) -> list[int] | None: ...
154 if sys.platform == "linux":
155 def cpu_num(self) -> int: ...
156 def environ(self) -> dict[str, str]: ...
157 if sys.platform == "win32":
158 def num_handles(self) -> int: ...
159 def num_ctx_switches(self) -> pctxsw: ...
160 def num_threads(self) -> int: ...
161 def threads(self) -> list[pthread]: ...
162 def children(self, recursive: bool = ...) -> list[Process]: ...
163 def cpu_percent(self, interval: float | None = ...) -> float: ...
164 def cpu_times(self) -> pcputimes: ...
165 def memory_info(self) -> pmem: ...
166 def memory_info_ex(self) -> pmem: ...
167 def memory_full_info(self) -> pfullmem: ...
168 def memory_percent(self, memtype: str = ...) -> float: ...
169 if sys.platform != "darwin":
170 def memory_maps(self, grouped: bool = ...): ...
171 def open_files(self) -> list[popenfile]: ...
172 def connections(self, kind: str = ...) -> list[pconn]: ...
173 def send_signal(self, sig: int) -> None: ...
174 def suspend(self) -> None: ...
175 def resume(self) -> None: ...
176 def terminate(self) -> None: ...
177 def kill(self) -> None: ...
178 def wait(self, timeout: int | None = ...) -> int: ...
180 _Popen = TypeVar("_Popen", bound="Popen")
182 class Popen(Process):
183 def __init__(self, *args, **kwargs) -> None: ...
184 def __enter__(self: _Popen) -> _Popen: ...
185 def __exit__(self, *args, **kwargs) -> None: ...
186 def __getattribute__(self, name: str) -> Any: ...
188 def pids() -> list[int]: ...
189 def pid_exists(pid: int) -> bool: ...
191 attrs: list[str] | Tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ...
192 ) -> Iterator[Process]: ...
194 procs: Iterable[Process], timeout: float | None = ..., callback: Callable[[Process], Any] | None = ...
195 ) -> tuple[list[Process], list[Process]]: ...
196 def cpu_count(logical: bool = ...) -> int: ...
197 def cpu_times(percpu: bool = ...): ...
198 def cpu_percent(interval: float | None = ..., percpu: bool = ...) -> float: ...
199 def cpu_times_percent(interval: float | None = ..., percpu: bool = ...): ...
200 def cpu_stats() -> scpustats: ...
201 def cpu_freq(percpu: bool = ...) -> scpufreq: ...
202 def getloadavg() -> tuple[float, float, float]: ...
203 def virtual_memory(): ...
204 def swap_memory() -> sswap: ...
205 def disk_usage(path: str) -> sdiskusage: ...
206 def disk_partitions(all: bool = ...) -> list[sdiskpart]: ...
207 def disk_io_counters(perdisk: bool = ..., nowrap: bool = ...) -> sdiskio: ...
208 def net_io_counters(pernic: bool = ..., nowrap: bool = ...) -> snetio: ...
209 def net_connections(kind: str = ...) -> list[sconn]: ...
210 def net_if_addrs() -> dict[str, list[snicaddr]]: ...
211 def net_if_stats() -> dict[str, snicstats]: ...
213 if sys.platform == "linux":
214 def sensors_temperatures(fahrenheit: bool = ...) -> dict[str, list[shwtemp]]: ...
215 def sensors_fans() -> dict[str, list[sfan]]: ...
217 if sys.platform != "win32":
218 def sensors_battery() -> sbattery | None: ...
220 def boot_time() -> float: ...
221 def users() -> list[suser]: ...
223 if sys.platform == "linux":
237 RLIMIT_SIGPENDING: int