Program randomly aborts when looking up url. The program loop thru
4000+ records looking
up ID via internet and returns html code which is used in subsequent
processing. The code
for looking-up record is below followed by abort details. Can anyone
help with catching the
abort before program aborts or provide code to automatically start
program? Currently, if
program is restarted the process starts after last good record but
must be restarted manually.

Thanks
Jim

code start here
================
#start lookups pass
while lines < 5000:
        lines += 1
        d =
ifile.read(8)

        print str(lines) + ' ' + d
        z = ifile.read(1)
        f2 = b + d
        h4 = h1+f2+h3                                    #file name for
saving HMTL file
        html_file = open(h4, 'w')
        url  = a + d + c + b                             #build url to
lookup record in database
        contents = urllib2.urlopen(url).read()           #lookup account in
database
        soup = BeautifulSoup(contents)
        html_file.write(soup.prettify())                 #write HTML file
        targetPage = soup.prettify()
        targetHTML = targetPage                          #set-up
record for edit pass
        html_file.close()                                #close HTML file


abort details
==============================
429 90078431(note:this record 429 is where abort happen-when program
restarted this record processed normally)

Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework
\scriptutils.py", line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "Lookup Records.py", line 77, in <module>
    contents = urllib2.urlopen(url).read()
  File "C:\Python25\lib\urllib2.py", line 121, in urlopen
    return _opener.open(url, data)
  File "C:\Python25\lib\urllib2.py", line 374, in open
    response = self._open(req, data)
  File "C:\Python25\lib\urllib2.py", line 392, in _open
    '_open', req)
  File "C:\Python25\lib\urllib2.py", line 353, in _call_chain
    result = func(*args)
  File "C:\Python25\lib\urllib2.py", line 1100, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "C:\Python25\lib\urllib2.py", line 1075, in do_open
    raise URLError(err)
URLError: <urlopen error (10053, 'Software caused connection abort')>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to