title: Checking for Timeout Error in python
body: <p>So I have a pretty generic logging statement after a request:</p>
  
  <pre><code>try:
      r = requests.get(testUrl, timeout=10.0)
  except Exception, err:
      logger.error({"message": err.message})
  </code></pre>
  
  <p>This works great for everything I've thrown at it except <code>TimeoutError</code>.  When the request times out the err I get back is a tuple that it tries and fails to serialize.</p>
  
  <p>My question is how do I catch just this one type of error?  For starters <code>TimeoutError</code> is not something I have access to.  I have tried adding <code>from exceptions import *</code> but with no luck.  I've also tried importing <code>OSError</code> because the docs say <code>TimeoutError</code> is a subclass, but I was unable to access <code>TimeoutError</code> after importing <code>OSError</code>.</p>
  
  <p><a href="https://docs.python.org/3/library/exceptions.html#TimeoutError" rel="noreferrer">TimeoutError docs</a></p>
  
  <p>I plan to either list my exceptions in order:</p>
  
  <pre><code>except TimeoutError, err:
       #handle this specific error
  except Exception, err:
       #handle all other errors
  </code></pre>
  
  <p>or just check for type:</p>
  
  <pre><code>except Exception, err:
      if isinstance(err, TimeoutError):
          #handle specific error
      #handle all other errors
  </code></pre>
  
  <p>Python 2.7.3 &amp; Django 1.5</p>