[Tutor] httplib exceptions

Bob Larsen bob at pbsit.com
Wed Aug 8 22:16:07 CEST 2007


I have written a script which checks all of my servers at predetermined 
intervals. 

code:

            try:
                page = urllib2.urlopen(url)
                soup= page.read()
                reex = re.compile(regex)
                test = re.findall(reex,soup)
            except ValueError,e:
                return 0
            if test:
                return 1
            else:
                return 0

Without the try clause the following exception is thrown:

Traceback (most recent call last):
  File "~/webcheck2.py", line 116, in ?
    if sitetest(url,search):
  File "~/webcheck2.py", line 71, in sitetest
    soup= page.read()
  File "/usr/lib/python2.4/socket.py", line 285, in read
    data = self._sock.recv(recv_size)
  File "/usr/lib/python2.4/httplib.py", line 460, in read
    return self._read_chunked(amt)
  File "/usr/lib/python2.4/httplib.py", line 499, in _read_chunked
    chunk_left = int(line, 16)
ValueError: invalid literal for int():

This script has been running well for months.  Within the past week it 
has started misbehaving.

There is a python Bug:
http://sourceforge.net/tracker/index.php?func=detail&aid=1486335&group_id=5470&atid=105470 
<http://sourceforge.net/tracker/index.php?func=detail&aid=1486335&group_id=5470&atid=105470>
that states this is caused by a missing EOF, and is "not a big deal"

At this point I am confused.

What exactly is causing this problem that didn't exist until a week ago?

How can I work Around this?

Any Insight is greatly appreciated

Bob Larsen


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the Tutor mailing list