Google App Engine: Determine whether Current Request is a Taskqueue
google-app-engine, python, task-queue
Solution
Pick any one of the following HTTP headers:
- `X-AppEngine-QueueName`, the name of the queue (possibly default)
- `X-AppEngine-TaskName`, the name of the task, or a system-generated unique ID if no name was specified
- `X-AppEngine-TaskRetryCount`, the number of times this task has been retried; for the first attempt, this value is 0
- `X-AppEngine-TaskETA`, the target execution time of the task, specified in microseconds since January 1st 1970.
Standard HTTP requests won't have these headers.
Problem
Is there a way to dynamically determine whether the currently executing task is a standard http request or a TaskQueue? In some parts of my request handler, I make a few urlfetches. I would like the timeout delay of the url fetch to be short if the request is a standard http request and long if it is a TaskQueue.