fix: Windows负载 — psutil.getloadavg() + 全0显示N/A

This commit is contained in:
qinglong
2026-06-14 10:32:51 +08:00
parent 7fe9e4f6cd
commit c65a9916c2
2 changed files with 8 additions and 2 deletions
+7 -1
View File
@@ -75,10 +75,16 @@ class SystemInfoCollector:
def _get_cpu(self) -> Dict[str, Any]:
if self.psutil:
load = [0, 0, 0]
if hasattr(os, 'getloadavg'):
load = os.getloadavg()
elif hasattr(self.psutil, 'getloadavg'):
try: load = list(self.psutil.getloadavg())
except: pass
return {
"percent": self.psutil.cpu_percent(interval=0.1),
"cores": self.psutil.cpu_count(),
"load_avg": os.getloadavg() if hasattr(os, 'getloadavg') else [0, 0, 0]
"load_avg": load
}
try:
load = os.getloadavg() if hasattr(os, "getloadavg") else [0.0, 0.0, 0.0]