0

I have a script that add tasks to a queue. For example:

api.py:

from google.appengine.api import taskqueue    
[...]
for u in users:
    taskqueue.add(queue_name='mailqueue', url="/api/users/send-notification/%s" % (u.id), method='GET')

I would like to check if the queue is empty and all tasks are finishing

view.py:

if queue_is_empty:
    print "Your task is finished"
Avara
  • 1,753
  • 2
  • 17
  • 24

1 Answers1

2

You can use the QueueStatistics class

statsList = taskqueue.QueueStatistics.fetch([taskqueue.Queue("foo"), taskqueue.Queue("bar")])

https://cloud.google.com/appengine/docs/python/taskqueue/queue_statistics#QueueStatistics_queue

Paul Collingwood
  • 9,053
  • 3
  • 23
  • 36