mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-01 05:54:46 +03:00
Crash when a process is pinned in the develop branch of Glances #2639
This commit is contained in:
parent
e3f63ed4ce
commit
67b5fe1a16
@ -426,3 +426,13 @@ def weak_lru_cache(maxsize=128, typed=False):
|
|||||||
return inner
|
return inner
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
def namedtuple_to_dict(data):
|
||||||
|
"""Convert a namedtuple to a dict, using the _asdict() method embeded in PsUtil stats."""
|
||||||
|
return {k: (v._asdict() if hasattr(v, '_asdict') else v) for k, v in data.items()}
|
||||||
|
|
||||||
|
|
||||||
|
def list_of_namedtuple_to_list_of_dict(data):
|
||||||
|
"""Convert a list of namedtuples to a dict, using the _asdict() method embeded in PsUtil stats."""
|
||||||
|
return [namedtuple_to_dict(d) for d in data]
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from glances.globals import BSD, LINUX, MACOS, WINDOWS, iterkeys
|
from glances.globals import BSD, LINUX, MACOS, WINDOWS, iterkeys
|
||||||
|
from glances.globals import namedtuple_to_dict, list_of_namedtuple_to_list_of_dict
|
||||||
from glances.timer import Timer, getTimeSinceLastUpdate
|
from glances.timer import Timer, getTimeSinceLastUpdate
|
||||||
from glances.filter import GlancesFilter
|
from glances.filter import GlancesFilter
|
||||||
from glances.programs import processes_to_programs
|
from glances.programs import processes_to_programs
|
||||||
@ -336,7 +337,7 @@ class GlancesProcesses(object):
|
|||||||
ret[stat_prefix + '_mean'] = ret[stat_prefix + '_mean_sum'] / ret[stat_prefix + '_mean_counter']
|
ret[stat_prefix + '_mean'] = ret[stat_prefix + '_mean_sum'] / ret[stat_prefix + '_mean_counter']
|
||||||
|
|
||||||
ret['extended_stats'] = True
|
ret['extended_stats'] = True
|
||||||
return ret
|
return namedtuple_to_dict(ret)
|
||||||
|
|
||||||
def is_selected_extended_process(self, position):
|
def is_selected_extended_process(self, position):
|
||||||
"""Return True if the process is the selected one for extended stats."""
|
"""Return True if the process is the selected one for extended stats."""
|
||||||
@ -422,7 +423,7 @@ class GlancesProcesses(object):
|
|||||||
# Grab extended stats only for the selected process (see issue #2225)
|
# Grab extended stats only for the selected process (see issue #2225)
|
||||||
if self.extended_process is not None and proc['pid'] == self.extended_process['pid']:
|
if self.extended_process is not None and proc['pid'] == self.extended_process['pid']:
|
||||||
proc.update(self.get_extended_stats(self.extended_process))
|
proc.update(self.get_extended_stats(self.extended_process))
|
||||||
self.extended_process = proc
|
self.extended_process = namedtuple_to_dict(proc)
|
||||||
|
|
||||||
# Meta data
|
# Meta data
|
||||||
###########
|
###########
|
||||||
@ -485,9 +486,7 @@ class GlancesProcesses(object):
|
|||||||
processlist = list(filter(lambda p: not self._filter.is_filtered(p), processlist))
|
processlist = list(filter(lambda p: not self._filter.is_filtered(p), processlist))
|
||||||
|
|
||||||
# Save the new processlist and transform all namedtuples to dict
|
# Save the new processlist and transform all namedtuples to dict
|
||||||
self.processlist = [
|
self.processlist = list_of_namedtuple_to_list_of_dict(processlist)
|
||||||
{k: (v._asdict() if hasattr(v, '_asdict') else v) for k, v in p.items()} for p in processlist
|
|
||||||
]
|
|
||||||
|
|
||||||
# Compute the maximum value for keys in self._max_values_list: CPU, MEM
|
# Compute the maximum value for keys in self._max_values_list: CPU, MEM
|
||||||
# Useful to highlight the processes with maximum values
|
# Useful to highlight the processes with maximum values
|
||||||
|
Loading…
Reference in New Issue
Block a user