Urllib2 and timeouts

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Johny

    #1

    Urllib2 and timeouts

    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.

  • Larry Bates

    #2
    Re: Urllib2 and timeouts

    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

    Comment

    Working...