We are offloading certain time consuming tasks using the GAE deferred library and would like to know how can we set the retry limit for those offloaded tasks. We are running
Check X-Appengine-Taskretrycount and X-Appengine-Taskexecutioncount http header values in your task.
If you don't want to retry a task, you can raise deferred.PermanentTaskFailure exception. This exception will be logged only, task won't run again.
Different ways to access http headers:
For http handlers triggered by taskqueue: num_tries = self.request.headers.get('X-AppEngine-TaskRetryCount')
For functions triggered by deferred library: num_tries = webapp2.get_request().headers.get('X-AppEngine-TaskRetryCount')