App Engine-使用Mapper API的任务队列重试计数
这是我想做的事情: 我使用新的Mapper API设置了MapReduce作业.这基本上可以正常工作. 问题是任务队列重试了所有失败的任务.但实际上我不希望他这样做. 是否可以从队列中删除任务或告诉它任务已成功完成?也许传递200状态代码?
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?
我知道我可以获取X-Appengine-Taskretrycount,但这并没有真正的帮助,因为我不知道如何停止任务.我尝试在try ..除了块中使用"pass",但这也不起作用.
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 :)
谢谢, 克里斯
在您的任务处理程序中执行此操作
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
希望这会有所帮助!