如何判断一组App Engine任务是否已全部完成? [英] How can I tell if a set of app engine tasks have all completed?

查看:57
本文介绍了如何判断一组App Engine任务是否已全部完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个循环,其中有100个任务入队,而每个任务都可能有一个任务入队,我怎么知道所有任务是否都已完成?

If I have a loop that enqueues say 100 tasks and each one of those tasks potentially enqueues a task, how can I tell if all tasks have completed?

我已经考虑过使用ShardedCounters解决此问题.完成每个任务后,我可以增加一个计数器,然后检查是否count ==100.当然,除非我进入这种递归计数方案,否则任务会产生自己的任务.我不确定掉进那个兔子洞是个好主意,因为分片的计数器似乎不是原子的.

I've thought about this problem using ShardedCounters. Once each task is completed, I could increment a counter then check to see if count == 100. Of course that falls apart with tasks spawning their own tasks unless I get into this recursive counting scenario. I'm not sure it's a good idea to go down that rabbit hole because it appears the sharded counters are not atomic.

推荐答案

您应该看看新的AppEngine 管道API .这是将昂贵的任务链接在一起并通知它们何时完成的一种方式.还有一个很棒的来自Google IO的视频会议进行演示.

You should take a look at the new AppEngine pipeline API. It's a way of chaining together expensive tasks, and notifying when they're complete. There's a also great video from the Google IO conference which demonstrates it.

这篇关于如何判断一组App Engine任务是否已全部完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆