title: Reading streaming http response with Python "requests" library
body: <p>I am trying to consume an event stream provided by the  <a href="https://github.com/googlecloudplatform/kubernetes">Kubernetes</a>
  api using the <code>requests</code> module.  I have run into what looks like a
  buffering problem: the <code>requests</code> module seems to lag by one event.</p>
  
  <p>I have code that looks something like this:</p>
  
  <pre><code>r = requests.get('http://localhost:8080/api/v1beta1/watch/services',
                   stream=True)
  
  for line in r.iter_lines():
      print 'LINE:', line
  </code></pre>
  
  <p>As Kubernetes emits event notifications, this code will only display
  the last event emitted when a new event comes in, which makes it
  almost completely useless for code that needs to respond to service
  add/delete events.</p>
  
  <p>I have solved this by spawning <code>curl</code> in a subprocess instead of using
  the <code>requests</code> library:</p>
  
  <pre><code>p = subprocess.Popen(['curl', '-sfN',
                        'http://localhost:8080/api/watch/services'],
                       stdout=subprocess.PIPE,
                       bufsize=1)
  
  for line in iter(p.stdout.readline, b''):
      print 'LINE:', line
  </code></pre>
  
  <p>This works, but at the expense of some flexibility.  Is there a way to
  avoid this buffering problem with the <code>requests</code> library?</p>