Hi,

Fab86 wrote:
Hello,

I am currently working on my program which send queries to Yahoo and
then saves them into a flatfile. The problem I have is that I need to
conduct 200 searches and Yahoo typically times out during the search
with an error. I have caught the error and told it to time.sleep(10)
however I can only think of deleting the flatfile and starting again
hoping that it will not time out again.

Is it possible to get the program to catch the exception, wait 10
seconds, then carry of from where it was rather than starting again?

If so, could someone please inform me how to do this?

for search in range(200):
    for t in range(MAXRETRY):
        try:
                result=requestfromserver(...)
                break
        except IOError,e: # or whaterver error you get
            time.sleep(10)
            # log something ...
    else: # if above runs w/o break
        raise XYZError...() # define appropriate for your app

    # here you can work with result


HTH
Tino

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

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

Reply via email to