Google App Engine: determine if the current request is a task

Is there a way to dynamically determine if the task currently running is a standard HTTP request or TaskQueue?

In some parts of my query handler, I am doing several urlfetches. I would like the URL fetch timeout delay to be short if the request is a standard HTTP request and long if it is a TaskQueue.

+4
source share
2 answers

Select any of the following HTTP headers:

  • X-AppEngine-QueueName , queue name (possibly the default)
  • X-AppEngine-TaskName , task name or system unique identifier, if no name is specified
  • X-AppEngine-TaskRetryCount , the number of repetitions of this task; for the first attempt, this value is 0
  • X-AppEngine-TaskETA , the target execution time specified in microseconds from January 1, 1970.

Standard HTTP requests will not have these headers.

+7
source

Task requests always include a specific set of HTTP headers that you can check.

+2
source

All Articles