I have a simple task that requires a 3rd party.
When a request comes, I push it to an amazon sqs
queue, pull it in a worker and call the 3rd party
. In case of a time out, I want to implement an exponential backoff (try again in 2 secs, then 4 then 8, then...)
with a max retry.
Using python
, boto -> sqs
I've looked for built in parameters to allow me to do so with as little code as possible (ideally, no code at all).
Something like
from boto import sqs
def handle_message(message):
try:
# send a post to api
except TimeOut, err:
# send_back_to_itself in 2/4/8 sec
if delay < DELAY_LIMIT:
queue.write(message, delay=secs)