title: Socket-timeout: timed out python requests
body: <p>Using the <code>requests</code> python lib, I make a GET request, and handle Timeout exceptions (as well as other exceptions I don't show here) like</p>
  
  <pre><code>import requests
  timeout1=20
  timeout2=40
  
  try:
      #first attempt
      resp = requests.get(base_url+resource, params=payload, headers=headers,
      timeout=timeout1)
  except requests.exceptions.Timeout:
      #timed out, retry once
      try:
         resp = requests.get(base_url+resource, params=payload, headers=headers,
         timeout=timeout2)
         return resp.json()
      except requests.exceptions.RequestException as e:
         #Still failed; return error code
         return -1
  </code></pre>
  
  <p>This works fine most of the time, however sometimes my program just completely exits with the error <code>socket.timeout: timed out</code>, instead of throwing the <code>requests.exceptions.Timeout</code> and this being caught and dealt with.</p>
  
  <p>Why is the requests lib behaving like this? How should I handle this?</p>