On Mar 19, 6:50 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Wed, 19 Mar 2008 14:45:39 -0700, Jim wrote:
> > Program randomly aborts when looking up url. The program loop thru
> > 4000+ records looking
> > up ID via internet and returnshtmlcode 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?
>
> Yes. Wrap the offending code with a try...except loop, something similar
> to this.
>
> try:
>     contents = urllib2.urlopen(url).read()
> except URLError, e:
>     if e.errno == 10053:
>         # "Software caused connection abort"
>         response = raw_input(
>             "Temporary failure, Skip/Halt/try Again?")
>         response = response.lower().strip()
>         if response in ('h', 'halt'):
>             break
>         elif response in ('a', 'again', 't', 'try', 'try again'):
>             continue
>         elif response in ('', 's', 'skip'):
>             lines -= 1
>             continue
>         else:
>             print "Unknown response, boo hiss to you!"
>             raise
>
> --
> Steven

Thanks Steven for recommendation.

The program is my first and I'm not a programmer so it will take me
some time to get your recommendation to work. So far the program runs
after I added code based on your example but the program still aborts
and none of the code ("Temporary failure, Skip/Halt/try Again?" or
"Unknown response, boo hiss to you!") in your example is displayed. It
appears to abort in the imported module "urllib2" which is open
source. The code in urllib2 is way over my skill level.

Jim
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to