2
votes

I have created a project under Google App Engine Python 2.7. I have created some tasks using queue.yaml and deployed with the glcoud command. When I go to the Google App Engine console under section "taskqueues", it redirects to the Cloud Tasks page. I can see my App Engine queues are listed under Cloud Tasks.

I have still not enabled 'Cloud Tasks API' service but when I launch background task which service is handling the queue? Then if I want to use Cloud Tasks service with App Engine Python 2.7, how should I proceed?

I have followed documentation https://cloud.google.com/tasks/docs/dual-overview in which for Python 2.7 we can access Cloud Tasks service via App engine Task Queue API. There are some key deferences using Cloud Tasks API service such as deferred queues. I just want to make sure that these features will be available when I move to Cloud Tasks. How can both services coexist?

2

2 Answers

1
votes

The "Cloud Tasks API" provides a REST API that you can use to add tasks from a second generation App Engine standard environment runtime, any of the App Engine flexible environment runtimes, or even from entirely outside of App Engine.

When you're creating first-generation App Engine push/pull queues, you're bypassing the need to use this API directly, however the tasks that are being created are on the same service as if you had created them with the Cloud Tasks API.

1
votes

In the 1st generation standard environment GAE (python 2.7) services you should continue to use the Task Queue API, there is no deprecation note for it.

Task Queue API is not available in the other environments, so for those services you have to use the newer Cloud Tasks API (which at least initially was based on a 1st gen standard environment service under the hood, but now it supports multiple HTTP endpoints).

You shouldn't worry too much about the Cloud Tasks page - it just make sense to manage both through a common GUI due to their similarities, but the 2 products continue to operate independently. Depending on which API you use you could, I suppose, use both features in the same time (for different tasks, of course) and manage both through the common GUI.

You can't exactly talk about which service handles a queue as tasks in the same queue could be handled by different services. For example in GAE push queues there are 3 ways for targeting a task:

  • Declare the target when you construct the task. You can set the target explicitly using the target parameter in the taskqueue.add() function. See the example above.
  • Include a target directive when you define a queue in the queue.yaml, as in the definition of queue-blue. All tasks added to a queue with a target will use that target, even if a different target was assigned to the task at construction time.
  • If no target is specified according to either of the previous two methods, then the task's target is the version of the service that enqueues it. Note that if you enqueue a task from the default service and version in this manner, and the default version changes before the task executes, it will run in the new default version.

In Cloud Tasks targeting is even wider - a task target isn't even necessarily a GAE service. From Cloud Tasks queues with HTTP targets:

In the case of generic HTTP Targets, the Cloud Tasks service forwards the task request to the worker, located at any generic HTTP endpoint, such as Cloud Functions, Cloud Run, GKE, Compute Engine, or even an on-prem web server, and based on how the task is configured.

The deferred queues is similarly misleading, you should be referring to deferred tasks. In general there are 2 main reasons for using them:

In some cases where you might need a series of diverse small tasks handled asynchronously but you don't want to go through the work of setting up individual distinct handlers, the App Engine SDK allows you to use runtime specific libraries to create simple functions to manage these tasks. This feature is not available in Cloud Tasks. Note, though, that normal tasks can be scheduled in the future using Cloud Tasks.