问题
here is what I'm trying to do: I set up a MapReduce job with the new Mapper API. This basically works fine. The problem is that the Task Queue retries all tasks that have failed. But actually I don't want him to do that. Is there a way to delete a task from the queue or tell it that the task was completed successfully? Perhaps passing a 200 status code?
I know that I can fetch the X-Appengine-Taskretrycount, but that doesn't really help since I don't know how to stop the task. I tried using a 'pass' in the try .. except block but that didn't work either.
Any help would be much appreciated :)
Thanks, Chris
回答1:
In your task handler do this
class yourTaskWorker(webapp.RequestHandler):
def post(self):
logging.info('yourTaskWorker (post)...')
if int(self.request.headers['X-Appengine-Taskretrycount']) == 0:
logging.info('running task...')
# call whatever functions you want here
else:
logging.info('this task failed before, not going to retry.')
# obviously call nothing here, the task will "pass" without error and go away
Hope this helps!!
回答2:
As of http://code.google.com/p/appengine-mapreduce/source/detail?r=114 change, context object has task_retry_count attribute.
来源:https://stackoverflow.com/questions/3342072/app-engine-task-queue-retry-count-with-mapper-api