title: Python howto exception handle <urlopen error [Errno 54] Connection reset by peer>
body: <p>My script in Python 2.7 scrapes a website every minute, but sometimes it gives the error:</p>
  
  <p>urlopen error [Errno 54] Connection reset by peer></p>
  
  <p>How I can handle the exception? I am trying something like this:</p>
  
  <pre><code>from socket import error as SocketError
  import errno
  
  try:
      response = urllib2.urlopen(request).read()
  except SocketError as e:
      if e.errno != errno.ECONNRESET:
          print "there is a time-out" 
      pass
          print "There is no time-out, continue" 
  </code></pre>