how best to handle httplib timeouts ?

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

    how best to handle httplib timeouts ?

    Hi all,

    I'm trying to write an app to monitor an IIS server, by connecting and
    getting a page via httplib. the problem seems to be when IIS (or ASP) dies
    httplib does not always return and sometimes I'm left with an app that
    hangs. what is the best way to handle this ?

    thanks,
    rich.

    the code looks like this:

    try:
    res = h.getresponse()
    dat = res.read()
    sFlag = sFlag + 1
    except:
    if debug > 0:
    WriteLog(' Error receiving a response from 2nd mailbox page
    request')
    h.close()
    return sFlag



  • Skip Montanaro

    #2
    Re: how best to handle httplib timeouts ?


    rich> I'm trying to write an app to monitor an IIS server, .... what is
    rich> the best way to handle this ?

    Off-topic response perhaps, but if you want to monitor services running on
    remote machines, you should see what's already available. I use Nagios,
    <http://www.nagios.org/>, and find it excellent for the purpose (a bit
    complex to get started with, but very robust).

    Skip

    Comment

    • Rich

      #3
      Re: how best to handle httplib timeouts ?


      "Skip Montanaro" <skip@pobox.com > wrote in message
      news:mailman.10 59571376.25384. python-list@python.org ...[color=blue]
      >
      > Off-topic response perhaps, but if you want to monitor services running on
      > remote machines, you should see what's already available. I use Nagios,
      > <http://www.nagios.org/>, and find it excellent for the purpose (a bit
      > complex to get started with, but very robust).
      >
      > Skip
      >[/color]
      Thanks Skip,
      Monitoring services themselves is a snap but I'm trying to monitor the state
      of IIS, and in particular the state of OWA running on IIS. OWA for Exchange
      5.5 is a bit flakey at best and it doesn't always show up as a service
      outage. The script I have so far connects to the server (using HTTPS) then
      passes a login request for a mailbox and retrieves the Inbox page. It does 5
      different requests in all and sometimes gets stuck on the third or fourth
      request. Running the source code version seems a little better than the one
      compiled with py2exe, and it will often return after what seems like a 2
      minute socket timeout. I've also tried playing with different settings for
      the default socket timeout value but that doesn't seem to help either. (I'm
      running 2.3b2)

      thanks,

      rich.


      Comment

      • Rich

        #4
        Re: how best to handle httplib timeouts ?


        "John J. Lee" <jjl@pobox.co m> wrote in message
        news:87k79zx5q6 .fsf@pobox.com. ..[color=blue]
        >[/color]
        [snip][color=blue]
        >
        > 1. Get 2.3final (I don't know whether there was a bug fix, but I have
        > a vague recollection there was some sort of problem with timeouts
        > -- see the python-dev summaries and/or SF bug archive).[/color]

        yes, this seems to have made the problem go away... I tried setting the
        default timeout but it still acted flakey and would not connect, so, I
        removed this and everything seems to be working, or at lest timing out
        correctly.

        2.3final also solved the "ImportErro r: No module named warnings" problem
        with py2exe and I think this may have had something to do with it.

        thanks,
        rich.


        Comment

        Working...