Sep-21-2021, 01:24 AM
Have you had a look at this doc?
I don't understand why you are putting the cpu_percent in a list bracket.
I don't understand why you are putting the cpu_percent in a list bracket.
#! /usr/bin/env python3 import psutil from time import sleep max_pct = 90 cpu_pct = psutil.cpu_percent(interval=0.1) cpu_pct2 = psutil.cpu_percent(interval=0.1, percpu=True) counter = 10 while counter != 0: print(f'cpu_pct: {cpu_pct} \ncpu_pct2: {cpu_pct2}\n') sleep(1) counter -= 1
Output:cpu_pct: 8.5
cpu_pct2: [14.3, 0.0, 14.3, 0.0, 14.3, 0.0, 0.0, 14.3, 0.0, 0.0, 0.0, 0.0]
cpu_pct: 8.5
cpu_pct2: [14.3, 0.0, 14.3, 0.0, 14.3, 0.0, 0.0, 14.3, 0.0, 0.0, 0.0, 0.0]
cpu_pct: 8.5
cpu_pct2: [14.3, 0.0, 14.3, 0.0, 14.3, 0.0, 0.0, 14.3, 0.0, 0.0, 0.0, 0.0]
cpu_pct: 8.5
cpu_pct2: [14.3, 0.0, 14.3, 0.0, 14.3, 0.0, 0.0, 14.3, 0.0, 0.0, 0.0, 0.0]
cpu_pct: 8.5
cpu_pct2: [14.3, 0.0, 14.3, 0.0, 14.3, 0.0, 0.0, 14.3, 0.0, 0.0, 0.0, 0.0]
cpu_pct: 8.5
cpu_pct2: [14.3, 0.0, 14.3, 0.0, 14.3, 0.0, 0.0, 14.3, 0.0, 0.0, 0.0, 0.0]
cpu_pct: 8.5
cpu_pct2: [14.3, 0.0, 14.3, 0.0, 14.3, 0.0, 0.0, 14.3, 0.0, 0.0, 0.0, 0.0]
cpu_pct: 8.5
cpu_pct2: [14.3, 0.0, 14.3, 0.0, 14.3, 0.0, 0.0, 14.3, 0.0, 0.0, 0.0, 0.0]
cpu_pct: 8.5
cpu_pct2: [14.3, 0.0, 14.3, 0.0, 14.3, 0.0, 0.0, 14.3, 0.0, 0.0, 0.0, 0.0]
cpu_pct: 8.5
cpu_pct2: [14.3, 0.0, 14.3, 0.0, 14.3, 0.0, 0.0, 14.3, 0.0, 0.0, 0.0, 0.0]
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags