Implement a minimum interval between cpu_percent() calls. Fixes #1738

This commit is contained in:
Bernhard Ehlers
2020-04-19 20:42:46 +02:00
parent 4ab100b716
commit 10bb259248
4 changed files with 55 additions and 3 deletions

View File

@ -19,6 +19,8 @@ import asyncio
import json
import psutil
from gns3server.utils.cpu_percent import CpuPercent
class NotificationQueue(asyncio.Queue):
"""
@ -51,7 +53,7 @@ class NotificationQueue(asyncio.Queue):
"""
msg = {}
# Non blocking call in order to get cpu usage. First call will return 0
msg["cpu_usage_percent"] = psutil.cpu_percent(interval=None)
msg["cpu_usage_percent"] = CpuPercent.get(interval=None)
msg["memory_usage_percent"] = psutil.virtual_memory().percent
return msg