urllib2 hangs "forever" where there is no network interface

dumbkiwi dmbkiwi at gmail.com
Thu Feb 1 13:04:23 EST 2007


On Feb 2, 5:02 am, j... at pobox.com (John J. Lee) wrote:
> "dumbkiwi" <dmbk... 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?

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

Sorry, I should have been more specific.  The network interfaces are
up - ie lo and eth1, it's where the wireless connection has dropped
out.  Is the best solution to test for a wireless connection through /
proc before trying to download data?




More information about the Python-list mailing list