title: Python non-blocking for loop
body: <p>I'm using the <a href="https://github.com/sixohsix/twitter" rel="nofollow">twitter</a> python package in pip to access the TwitterStream class.</p>
  
  <p>The code for this looks somewhat like this:</p>
  
  <pre><code>twitter_stream = TwitterStream(auth=UserPassAuth('joe', 'joespassword')) 
  iterator = twitter_stream.statuses.sample()
  
  for tweet in iterator:
      # ...do something with this tweet...
  </code></pre>
  
  <p>I only want the for loop to run for a certain amount of time (say, one minute), so to do this, I inserted a time check in the for loop. My problem though is that if the tweets aren't getting pushed frequently enough, then the body of the for loop never executes and the code essentially hangs until the next tweet comes in.</p>
  
  <p>Does anyone have any ideas on how to get around this? The block param from the docs doesn't return often enough when set to false.</p>
  
  <p>Thanks</p>