MCPcopy Create free account
hub / github.com/nlweb-ai/NLWeb / start_monitoring

Method start_monitoring

tests/performance/test_load.py:57–79  ·  view source on GitHub ↗

Start continuous monitoring.

(self)

Source from the content-addressed store, hash-verified

55 }
56
57 async def start_monitoring(self):
58 """Start continuous monitoring."""
59 self.monitoring = True
60
61 async def monitor_loop():
62 while self.monitoring:
63 # Record system metrics
64 process = psutil.Process()
65
66 self.metrics["memory_usage"].append({
67 "timestamp": time.perf_counter(),
68 "memory_mb": process.memory_info().rss / 1024 / 1024,
69 "memory_percent": process.memory_percent()
70 })
71
72 self.metrics["cpu_usage"].append({
73 "timestamp": time.perf_counter(),
74 "cpu_percent": process.cpu_percent(interval=None)
75 })
76
77 await asyncio.sleep(1.0) # Monitor every second
78
79 self.monitor_task = asyncio.create_task(monitor_loop())
80
81 def stop_monitoring(self):
82 """Stop monitoring and return final metrics."""

Calls

no outgoing calls

Tested by

no test coverage detected