Why does my bottlenose ErrorHandler not handle 503's

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:
        time.sleep(random.expovariate(0.1))
        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
LVL 9
Evan CutlerVolunteer Chief Information OfficerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Evan CutlerVolunteer Chief Information OfficerAuthor Commented:
well, it's ugly, but it works.  I just wish I didn't have to take so long.
Thanks
Evan
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.