urllib IOError Exception

John J. Lee jjl at pobox.com
Sun Jun 13 20:02:41 EDT 2004


Bart Nessux <bart_nessux at hotmail.com> writes:

> JanC wrote:
> > Bart Nessux <bart_nessux at hotmail.com> schreef:
> >
> >>        try:
> >>           f = urllib2.urlopen("http://%s" %host)
> >>        except urllib2.URLError:
> >>           print host, "has no http server on  port 80"
> >>
> >>Anyway to speed this up??? The timeout per host is several minutes.
> > socket.setdefaulttimeout(timeout)
> > <http://docs.python.org/lib/module-socket.html>
> >
> 
> Thanks, that worked... I find it odd that I have to import the socket
> module to set a timeout while using the urllib2 module... why isn't
> there a  function in urllib2 that can handle this?

Because nobody wrote one.

Go ahead and add upload a patch :-)


John



More information about the Python-list mailing list