title: Python break if a condition stays false for some time
body: <p>I am writing a program for real time pitch detection. Here's the outline of the code :-</p>
  
  <pre><code>def pitch_detection :
  
      result = []
      while True :
  
          // apply pitch detection algorithm
  
          if pitch_energy &gt; threshold :
              result.append(pitch)
  
      return result       
  </code></pre>
  
  <p>I want to brrak from the loop if <code>pitch_energy &gt; threshold</code> is <code>False</code> for sometime </p>
  
  <p>What I am doing right now is timeout the loop after sometime. 
  Like this :-
  <a href="https://stackoverflow.com/questions/13293269/">How would I stop a while loop after n amount of time?</a></p>