title: Python Requests package: lost connection while streaming
body: <p>I'd like to use the Requests package to connect to the streaming API of a web service. Suppose I use the following code to send a request, receive the response and iterate through the lines of response as they arrive: </p>
  
  <pre><code>import requests
  
  r = requests.get('http://httpbin.org/stream/20', stream=True)
  for line in r.iter_lines():
      if line:
          print line
  </code></pre>
  
  <p>While waiting to receive new data, we are basically waiting for r.iter_lines() to generate a new piece of data. But what if I lose internet connection while waiting? How can I find out so I can attempt to reconnect?</p>