MCPcopy Create free account
hub / github.com/ParzivalHack/PySpector / _monitor

Method _monitor

src/pyspector/stats.py:188–199  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

186 proc = psutil.Process()
187
188 def _monitor() -> None:
189 peak = 0.0
190 while not self._stop_evt.wait(timeout=0.15):
191 try:
192 mem = proc.memory_info().rss / 1_048_576 # bytes → MB
193 peak = max(peak, mem)
194 cpu = proc.cpu_percent()
195 if cpu > 0:
196 self._cpu_samples.append(cpu)
197 except Exception:
198 break
199 self.peak_memory_mb = peak
200
201 self._mon_thread = threading.Thread(target=_monitor, daemon=True)
202 self._mon_thread.start()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected