How can I tell if a set of app engine tasks have all completed?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 05:12:39

问题


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?

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.


回答1:


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.




回答2:


Depending upon the scenario, you can test to see if any tasks (matching some pattern or having a certain ID/etc) are currently en-queued using the REST API:

http://code.google.com/appengine/docs/python/taskqueue/rest.html#method_taskqueue_tasks_list



来源:https://stackoverflow.com/questions/8964234/how-can-i-tell-if-a-set-of-app-engine-tasks-have-all-completed

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