urllib2 hangs "forever" where there is no network interface

John J. Lee jjl at pobox.com
Thu Feb 1 11:02:08 EST 2007


"dumbkiwi" <dmbkiwi at gmail.com> writes:

> I have written a script that uses the urllib2 module to download web
> pages for parsing.
> 
> If there is no network interface, urllib2 hangs for a very long time
> before it raises an exception.  I have set the socket timeout with
> socket.setdefaulttimeout(), however, where there is no network
> interface, this seems to be ignored - presumably, because without a
> network interface, there is nothing for the socket module to interact
> with.
> 
> So, can someone point me in the right direction, so that I can catch
> an exception where there is no network interface?

Are you on Windows or something Unixy?

Presumably Windows?  (Unix systems almost always have at least a
loopback interface)


John




More information about the Python-list mailing list