feat(mma): Finalize Orchestrator Integration and fix all regressions
This commit is contained in:
@@ -38,11 +38,21 @@ class PerformanceMonitor:
|
||||
|
||||
def _monitor_cpu(self):
|
||||
while not self._stop_event.is_set():
|
||||
# psutil.cpu_percent is better than process.cpu_percent for real-time
|
||||
usage = self._process.cpu_percent(interval=1.0)
|
||||
with self._cpu_lock:
|
||||
self._cpu_usage = usage
|
||||
time.sleep(0.1)
|
||||
# psutil.cpu_percent with interval=1.0 is blocking for 1 second.
|
||||
# To be responsive to stop_event, we use a smaller interval or no interval
|
||||
# and handle the timing ourselves.
|
||||
try:
|
||||
usage = self._process.cpu_percent()
|
||||
with self._cpu_lock:
|
||||
self._cpu_usage = usage
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Sleep in small increments to stay responsive to stop_event
|
||||
for _ in range(10):
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
time.sleep(0.1)
|
||||
|
||||
def start_frame(self):
|
||||
self._start_time = time.time()
|
||||
|
||||
Reference in New Issue
Block a user