how best to handle httplib timeouts ?

R

Rich

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
 
S

Skip Montanaro

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
 
R

Rich

Skip Montanaro said:
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
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.
 
R

Rich

John J. Lee said:
[snip]

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).

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 "ImportError: No module named warnings" problem
with py2exe and I think this may have had something to do with it.

thanks,
rich.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top