New Graph Element ! Graph on a canvas using your own coordinate system. Demo program for Graph Element, Exception handling for CPU widget. Sometimes as getting error from psutil

This commit is contained in:
MikeTheWatchGuy 2018-09-16 17:08:26 -04:00
parent 25a5266dce
commit 4ad786c27c
3 changed files with 117 additions and 9 deletions

View file

@ -27,8 +27,11 @@ def CPU_thread(args):
global g_interval, g_cpu_percent, g_procs, g_exit
while not g_exit:
g_cpu_percent = psutil.cpu_percent(interval=g_interval)
g_procs = psutil.process_iter()
try:
g_cpu_percent = psutil.cpu_percent(interval=g_interval)
g_procs = psutil.process_iter()
except:
pass
def main():
@ -67,7 +70,10 @@ def main():
display_string = ''
if g_procs:
# --------- Create list of top % CPU porocesses --------
top = {proc.name() : proc.cpu_percent() for proc in g_procs}
try:
top = {proc.name() : proc.cpu_percent() for proc in g_procs}
except: pass
top_sorted = sorted(top.items(), key=operator.itemgetter(1), reverse=True)
if top_sorted: