diff options
author | nicolargo <nicolashennion@gmail.com> | 2024-06-26 18:56:31 +0200 |
---|---|---|
committer | nicolargo <nicolashennion@gmail.com> | 2024-06-26 18:56:31 +0200 |
commit | f6066e5d4672f415ae2aff1f99b421aa96456808 (patch) | |
tree | 91ebfd3ccfd52c040fbd470be7b7b2ab305ee731 | |
parent | cff2e9fc4a72948d96e604f97bf20e68185afa18 (diff) |
PsUtil 6+ no longer check PID reused #2755
-rw-r--r-- | glances/processes.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/glances/processes.py b/glances/processes.py index a01cd929..9487b9ef 100644 --- a/glances/processes.py +++ b/glances/processes.py @@ -123,7 +123,9 @@ class GlancesProcesses: """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""" @@ -451,7 +453,9 @@ class GlancesProcesses: ) ) # 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) |