Skip to content Skip to sidebar Skip to footer

Retry Count In Deferred.defer In GAE

I'm using GAE's 'deffered' library (python), which automatically retries the task in the event an exception is raised. Is there a way to know (within the task handler function) th

Solution 1:

There are several headers will be set automatically with task https://developers.google.com/appengine/docs/python/taskqueue/overview-push

X-AppEngine-TaskRetryCount, the number of times this task has been retried; for the first attempt, this value is 0. This number includes attempts where the task failed due to a lack of available instances and never reached the execution phase.

X-AppEngine-TaskExecutionCount, the number of times this task has previously failed during the execution phase. This number does not include failures due to a lack of available instances.

EDIT 1

These values can access:

num_tries  = self.request.headers.get('X-AppEngine-TaskRetryCount')

EDIT 2

http://webapp-improved.appspot.com/api/webapp2.html#webapp2.get_request

for defered try:

request = webapp2.get_request()

Post a Comment for "Retry Count In Deferred.defer In GAE"