Skip to content

Commit

Permalink
PsUtil 6+ no longer check PID reused #2755
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolargo committed Jun 26, 2024
1 parent cff2e9f commit f6066e5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions glances/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ def reset_internal_cache(self):
"""Reset the internal cache."""
self.cache_timer = Timer(0)
self.processlist_cache = {}
psutil.process_iter.cache_clear()
if hasattr(psutil.process_iter, 'cache_clear'):
# Cache clear only available in PsUtil 6 or higher
psutil.process_iter.cache_clear()

def reset_processcount(self):
"""Reset the global process count"""
Expand Down Expand Up @@ -451,7 +453,9 @@ def update(self):
)
)
# Only get the info key
processlist = [p.info for p in processlist]
# PsUtil 6+ no longer check PID reused #2755 so use is_running in the loop
# Note: not sure it is realy needed but CPU consumption look teh same with or without it
processlist = [p.info for p in processlist if p.is_running()]
# Sort the processes list by the current sort_key
processlist = sort_stats(processlist, sorted_by=self.sort_key, reverse=True)

Expand Down

0 comments on commit f6066e5

Please sign in to comment.