lionheart / bottlenose

A Python wrapper for the Amazon Product Advertising API.
Apache License 2.0
577 stars 112 forks source link

How to add ERROR HANDLER to active Bottlenose connection #32

Closed arcee123 closed 7 years ago

arcee123 commented 10 years ago

I am getting 503's. According to your 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

Your instruction says use this line:

amazon = bottlenose.Amazon(ErrorHandler=error_handler)

I have this:

amazon = bottlenose.Amazon(AWSAccessKeyId=ACCESS_KEY_ID, AWSSecretAccessKey = SECRET_KEY,AssociateTag = ASSOC_TAG)

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)

But I'm still getting 503's. I assume I am not setting it right. I'm hoping you might be able to tell me where I am missing this. Thank you

stephnr commented 10 years ago

Please refer to this Gist as an example of how to retrieve data from the Amazon API using Bottlenose

https://gist.github.com/Stephn-R/8644621

If you have any questions, feel free to ask.

arcee123 commented 10 years ago

Hi, thank you. I have the bottlenose/amazon api script in place. it does work....but amazon's load balancing is causing requests to stop. I am told that the Error_Handler script will handle Amazon's throttling mechanisms, but it appears I'm not doing it right. Can you help me? I need to know if I messed it up? or is there something I'm missing....

Thank you

stephnr commented 10 years ago

How many requests are you making? Is the data your requesting considered to be "high volume"? Amazon does allow data requests but if you request too much at once, you will be prevented via a 503.

dlo commented 7 years ago

I've created a "bottlenose" tag on Stack Overflow and encourage anyone running into usage-related questions there instead of here on the issue tracker. Please only open a new issue if you find a bug or have a feature request. Thanks! ✨