Skip to content

Commit

Permalink
Call process_iter.clear_cache() (PsUtil 6+) when Glances user force a…
Browse files Browse the repository at this point in the history
… refresh (F5 or CTRL-R) #2753
  • Loading branch information
nicolargo committed Jun 26, 2024
1 parent e5d5351 commit cff2e9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion glances/outputs/glances_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def _handle_quit(self, return_to_browser):
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"""
Expand Down
6 changes: 6 additions & 0 deletions glances/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ def set_args(self, args):
"""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}
Expand Down

0 comments on commit cff2e9f

Please sign in to comment.