fix

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

Likely causes

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

  1. 1Add sleep, backoff, or exit conditions
  2. 2Log loop progress and iteration counts
  3. 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

Related

Python infinite loop CPU: how to spot it | cpum.ai