-->

Getting the Tasks in a Google App Engine TaskQueue

2020-07-10 20:08发布

问题:

I know you can view the currently queued and running tasks in the Dashboard or development server console. However, is there any way to get that list programmatically? The docs only describe how to add tasks to the queue, but not how to list and/or cancel them.

In python please.

回答1:

It sure doesn't look that way. Instead of removing the task, how about altering the task handler, whatever it is that handles the task url invokes, to check to see if the work specified still needs to be done, and just return 200 OK immediately if the task would be deleted.

This issue on google-code appears to request the very same feature.



回答2:

A workaround, since they don't seem to support this yet, would be to model a Task datastore object. Create one on task queue add, update it when running, and delete it when your task fires. This can also be a nice way to get around the payload limits of the task queue api.



回答3:

If you use pull queues, this can be accomplished using the Task Queue REST API via:

GET
https://www.googleapis.com/taskqueue/v1beta1/projects/{PROJECT_NAME}/taskqueues/{TASKQUEUE_NAME}/tasks

Right now, this is only possible using pull queues:

"You can only use push queues within the App Engine environment; if you need to access App Engine tasks from outside of App Engine, use pull queues." -Push Queue docs