App Engine - 使用 Mapper API 进行任务队列重试计数

发布于 2024-09-11 12:50:26 字数 273 浏览 8 评论 0原文

这就是我想做的: 我使用新的 Mapper API 设置了 MapReduce 作业。这基本上工作得很好。 问题是任务队列重试所有失败的任务。但其实我不想让他这么做。 有没有办法从队列中删除任务或告诉它任务已成功完成?也许传递 200 状态代码?

我知道我可以获取 X-Appengine-Taskretrycount,但这并没有真正帮助,因为我不知道如何停止任务。我尝试在 try .. except 块中使用“pass”,但这也不起作用。

任何帮助将不胜感激:)

谢谢, 克里斯

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

骑趴 2024-09-18 12:50:27

http://code.google.com/p/appengine 起-mapreduce/source/detail?r=114 更改,上下文对象具有task_retry_count属性。

As of http://code.google.com/p/appengine-mapreduce/source/detail?r=114 change, context object has task_retry_count attribute.

萌辣 2024-09-18 12:50:27

在您的任务处理程序中执行此操作


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

希望这有帮助!

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!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文