[Tutor] httplib exceptions
Kent Johnson
kent37 at tds.net
Wed Aug 8 23:07:51 CEST 2007
Bob Larsen wrote:
> 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
Not much to add but sympathy...I occasionally see this error also when
reading web pages from public servers.
My read on the bug report is
- they think it is an error in the data coming from the server
- they don't know the right way to fix it
So, has anything changed on the servers you are pinging? an upgrade to a
new version or change to a different server?
I guess you could try the patch, I haven't been that adventurous.
Kent
More information about the Tutor
mailing list