0

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

The examples in the instruction says to 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 someone might be able to tell me where I am missing this. Thank you

Dan Loewenherz
  • 10,879
  • 7
  • 50
  • 81
arcee123
  • 101
  • 9
  • 41
  • 118

1 Answers1

0

Are you submitting requests too quickly? You need to slow down. One request per second is a good speed.

The Amazon Product Advertising API returns errors in three categories so that you can easily determine how best to handle the problem:

  • 2XX errors are caused by mistakes in the request. For example, your request might be missing a required parameter. The error message in the response gives a clear indication what is wrong.
  • 4XX errors are non-transient errors. Upon receiving this error, resubmit the request.
  • 5XX errors are transient errors reflecting an error internal to Amazon. A 503 error means that you are submitting requests too quickly and your requests are being throttled. If this is the case, you need to slow your request rate to one request per second.
Stephen Lin
  • 4,852
  • 1
  • 13
  • 26
  • Thank you so much for your input. From what I understood, the instructions in the bottlenose guidance was to add a Error_handler that would force the retry. My code above was that attempt as per their instructions. but it's not working. I'm trying to figure out how to make it work. – arcee123 Aug 12 '14 at 03:27
  • @arcee123 random.expovariate(0.1) will get value less than 1 sometimes. Try to use time.sleep(2) to check if 503 happens again. – Stephen Lin Aug 12 '14 at 04:09
  • so, what you are saying, is that unless I force the wait time past the second, repeated attempts in the subsecond ruling might continuously put me in a bad 503 loop? – arcee123 Aug 12 '14 at 18:39
  • @arcee123 Yes. You can give it a try and tell me if it works. – Stephen Lin Aug 13 '14 at 00:48