Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Why does my bottlenose ErrorHandler not handle 503's

Posted on 2014-08-11
2
Medium Priority
?
418 Views
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:
        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
0
Comment
Question by:Evan Cutler
2 Comments
 
LVL 84

Accepted Solution

by:
David Johnson, CD, MVP earned 2000 total points
ID: 40255972
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
 
LVL 9

Author Closing Comment

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

Featured Post

Cyber Threats to Small Businesses (Part 2)

The evolving cybersecurity landscape presents SMBs with a host of new threats to their clients, their data, and their bottom line. In part 2 of this blog series, learn three quick processes Webroot’s CISO, Gary Hayslip, recommends to help small businesses beat modern threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Considering cloud tradeoffs and determining the right mix for your organization.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

810 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