• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 448
  • Last Modified:

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
0
Evan Cutler
Asked:
Evan Cutler
1 Solution
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now