Python infinite loop CPU
An infinite loop is one of the fastest ways to peg CPU. Even a loop that technically exits can behave like one if it spins too tightly.
Common symptoms
- Python process instantly spikes CPU
- No useful progress despite high activity
- Restarts temporarily clear the issue
Likely causes
- Missing break condition
- Polling loop without sleep
- Retry loop with no backoff
Evidence to look for
Same process stays hot without output progress
Function samples repeat the same stack pattern
CPU stays high even with low external traffic
What it usually means
The system appears 'busy' but the process is often redoing the same useless work repeatedly.
What to do next
- 1Add sleep, backoff, or exit conditions
- 2Log loop progress and iteration counts
- 3Use profiling to prove where the spin occurs
See what's causing your CPU
cpum.ai turns CPU, process, disk, and memory signals into plain-English explanations with evidence.
Open cpum.ai