Call process_iter.clear_cache() (PsUtil 6+) when Glances user force a refresh (F5 or CTRL-R) #2753

This commit is contained in:
nicolargo 2024-06-26 18:36:10 +02:00
parent e5d5351d31
commit cff2e9fc4a
2 changed files with 7 additions and 1 deletions

View File

@ -370,7 +370,7 @@ class _GlancesCurses:
logger.info(f"Stop Glances (keypressed: {self.pressedkey})")
def _handle_refresh(self):
pass
glances_processes.reset_internal_cache()
def loop_position(self):
"""Return the current sort in the loop"""

View File

@ -119,6 +119,12 @@ class GlancesProcesses:
"""Set args."""
self.args = args
def reset_internal_cache(self):
"""Reset the internal cache."""
self.cache_timer = Timer(0)
self.processlist_cache = {}
psutil.process_iter.cache_clear()
def reset_processcount(self):
"""Reset the global process count"""
self.processcount = {'total': 0, 'running': 0, 'sleeping': 0, 'thread': 0, 'pid_max': None}