title: Reusing httplib.HTTPConnection in python 2.7
body: <p>I recently inherited a python project, and I'm working on maintaining it now.  Part of the code makes a few hundred thousand requests from a website and saves the results to a database.  The code is reusing the same httplib.HTTPConnection object for reach request and then just looping over a </p>
  
  <pre><code>conn.request("GET",someString,'',headers)
  
  response = conn.getresponse()
  </code></pre>
  
  <p>section.  A few days ago in my logs I saw that one of the requests threw the exception:</p>
  
  <pre><code>[Errno 104] Connection reset by peer  
  </code></pre>
  
  <p>followed by every other conn.request() failing.  My first inclination was to just build a new connection for each request, but the perfomance impact of that was profound and horrible.  So my question is, how do I fix this, especially since I'm not 100% sure how I can even really test this.</p>
  
  <p>If I just call conn.connect() after an exception, will it correctly reconnect?  </p>
  
  <p>I'm looking for advise on how to fix it and possibly how I could test it.</p>
  
  <p>Thanks for your time.</p>