This is a new issue I am running into prior to my last question about updating data in loops. I have a small script reading in CPU time and flashing LED's when it hits a certain percentage, when I hit 100% CPU I want the LED's to be continuously blinking, so i put it in a while loop, but the script will hang and stay at 100 once it reaches there, but if it goes down the script will hang at 100 and won't update, I wrote a nested loop inside the while loop to update the CPU but still hangs here. I know it is hanging from that while loop that I have, but I need to while loop to keep the continuous flashing, is there anyway to keep that while loop while updating the cpu time?
this what I had:
while True:
cpu_time = psutil.cpu_percent(interval=1,percpu=False)
print cpu_time
if cpu_time>0:
led_blink()
print cpu_time
elif cpu_time>0 and cpu_time<10:
led_blink()
print cpu_time
#same elif loops for for 30%, 50%, 75% until 100% i get a hang
elif cpu_time>90:
while cpu_time>90:
print cpu_time
led_blink()
if cpu_time < 90:
break
#also tried using 'continue' but same result