From d5cf490f83099d9ab200b044455f4468d02f233c Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sat, 7 Jul 2018 21:40:24 +0200 Subject: [PATCH] Glances crash with extended process stats #1283 --- NEWS | 1 + glances/processes.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 060ac01f..9d08a728 100644 --- a/NEWS +++ b/NEWS @@ -61,6 +61,7 @@ Bugs corrected: * Crashes when influxdb option set #1260 * AMP for kernel process is not working #1261 * Arch linux package (2.11.1-2) psutil (v5.4.1): RuntimeWarning: ignoring OSError #1203 + * Glances crash with extended process stats #1283 Backward-incompatible changes: diff --git a/glances/processes.py b/glances/processes.py index 71efb168..9fbf368a 100644 --- a/glances/processes.py +++ b/glances/processes.py @@ -300,7 +300,8 @@ class GlancesProcesses(object): try: extended['tcp'] = len(top_process.connections(kind="tcp")) extended['udp'] = len(top_process.connections(kind="udp")) - except psutil.AccessDenied: + except (psutil.AccessDenied, psutil.NoSuchProcess): + # Manage issue1283 (psutil.AccessDenied) extended['tcp'] = None extended['udp'] = None except (psutil.NoSuchProcess, ValueError, AttributeError) as e: @@ -396,8 +397,8 @@ def sort_stats(stats, sortedby=None, reverse=True): process[sortedby][3], reverse=reverse) except Exception: - stats.sort(key=lambda x:(weighted(x['cpu_percent']), - weighted(x['memory_percent'])), + stats.sort(key=lambda x: (weighted(x['cpu_percent']), + weighted(x['memory_percent'])), reverse=reverse) else: # Others sorts