How to catch socket timeout?
__peter__ at web.de
Sun Sep 21 18:53:02 CEST 2003
Alan Kennedy wrote:
> What is wrong with the following code? It seems to do what you need:
> from urllib2 import urlopen
> import socket
> import sys
> slowurl = "http://127.0.0.1/cgi-bin/longWait.py?wait=10"
> data = urlopen(slowurl)
> except socket.error:
> errno, errstr = sys.exc_info()[:2]
> if errno == socket.timeout:
> print "There was a timeout"
> print "There was some other socket error"
You are right. I did not read the traceback carefully.
More information about the Python-list