App Engine - Task Queue Retry Count with Mapper API

99封情书 提交于 2019-12-11 06:28:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!