Specifying retry limit for tasks queued using GAE deferred library

前端 未结 3 958
暗喜
暗喜 2020-12-22 12:04

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

3条回答
  •  春和景丽
    2020-12-22 12:21

    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')

提交回复
热议问题