Why does my bottlenose ErrorHandler not handle 503's

Posted on 2014-08-11
Last Modified: 2014-08-14
I am getting 503's. According to bottlenose's instructions, I need to add a error_handler as per instructions. in the instructions I placed the function:
def error_handler(err):
    ex = err['exception']
    if isinstance(ex, HTTPError) and ex.code == 503:
        return True

Open in new window

The examples in the instruction says to use this line:
amazon = bottlenose.Amazon(ErrorHandler=error_handler)

Open in new window

I have this:
amazon = bottlenose.Amazon(AWSAccessKeyId=ACCESS_KEY_ID, AWSSecretAccessKey = SECRET_KEY,AssociateTag = ASSOC_TAG)

Open in new window

I tried to add the option several ways, such as this:
amazon = bottlenose.Amazon(AWSAccessKeyId=ACCESS_KEY_ID, AWSSecretAccessKey = SECRET_KEY,AssociateTag = ASSOC_TAG,ErrorHandler=error_handler)

Open in new window

But I'm still getting 503's. I assume I am not setting it right. I'm hoping someone might be able to tell me where I am missing this. Thank you
Question by:Evan Cutler
    LVL 77

    Accepted Solution

    A 503 error means that you are submitting requests too quickly and your requests are being throttled once you get one you have to wait a second or two then retry othewise your queue will be full of the initial 503 so you immediately send another request which also gets a 593 then you are stuck in an infinite loop of 503 and 503 error handlers.

     time.sleep(random.expovariate(0.1))  is too small
    sleep(randint(1,5) should do it.
    LVL 9

    Author Closing Comment

    by:Evan Cutler
    well, it's ugly, but it works.  I just wish I didn't have to take so long.

    Featured Post

    Don't lose your head updating email signatures!

    Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users should you!

    Join & Write a Comment

    When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
    When the confidentiality and security of your data is a must, trust the highly encrypted cloud fax portfolio used by 12 million businesses worldwide, including nearly half of the Fortune 500.
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now