Search code examples
pythongoogle-app-enginegoogle-cloud-platformtask-queuegoogle-cloud-tasks

Does the googleapis's list_tasks include the running tasks?


I am using the googleapis.dev to connect with my cloud task queue. I want to make sure that the queue is empty and the tasks are done. The question is, does the "list_tasks" function return only the scheduled tasks, or does it also include that tasks that are currently running?


Solution

  • The API suggests performing a list on the tasks in a queue will return an array of tasks like so:

    {
      "tasks": [
        {
          object (Task)
        }
      ],
      "nextPageToken": string
    }
    

    An example task object is like so:

    {
      "name": string,
      "scheduleTime": string,
      "createTime": string,
      "dispatchDeadline": string,
      "dispatchCount": integer,
      "responseCount": integer,
      "firstAttempt": {
        object (Attempt)
      },
      "lastAttempt": {
        object (Attempt)
      },
      "view": enum (View),
    
      // Union field payload_type can be only one of the following:
      "appEngineHttpRequest": {
        object (AppEngineHttpRequest)
      },
      "httpRequest": {
        object (HttpRequest)
      },
      "pullMessage": {
        object (PullMessage)
      }
      // End of list of possible types for union field payload_type.
    }
    

    According to the docs :

    If responseTime is unset, then the task has not been attempted or is currently running and the responseStatus field is meaningless.

    TL;DR Yes, running tasks are displayed