Urllib2 and timeouts

Larry Bates larry.bates at websafe.com
Wed Feb 14 12:02:38 EST 2007


Johny wrote:
> In my script I started using urllib2 to connect to a list of
> servers.It works well but only  until  a server from the list is not
> available.Then if it is down , there is a timeout and my script ends
> with the error.
> So, if I have a list of 10 servers, and the second from the list is
> not available , no others are used.
> Is there a way how to solve that problem, so that servers after  the
> server that is  not available will be used  too?
> Thanks for help
> L.
> 
Wrap your connection inside a try: block.  That way you can catch
the exception and continue your loop.

-Larry



More information about the Python-list mailing list