Raspberry Pi High CPU Utilization

So if you are coding in python for your Raspberry Pi and your script runs a loop you may have noticed the high cpu utilization, or not. I have not had an issue (yet) with the Pi running in the 90%, I have had a test Pi on my bench running for a few days with no problems so far. Least to say that it still is an issue.

Now I cannot claim to be the author of this fix, I found it while digging through the RPi forums one day. If your Pi is having this issue, simply add this line of code here and there during your loop:

time.sleep(0.1)

TA-DA! It really is that simple. I added one time.sleep(0.1) call between each of my IF/THENs and I watched (via top) my cpu go from 90-98% to under 5%!!


Discover more from Its_All.Lost

Subscribe to get the latest posts sent to your email.

Leave a Reply