Search code examples
google-app-enginegoogle-cloud-platform

Prevent DeferredTask from retrying if it fails in Google App Engine


I noticed that the com.google.appengine.api.taskqueue.DeferredTask in the Google Cloud retries if it throws an exception. Is there a way to have it not retry if it gets an error?

Note: using JAVA


Solution

  • With first gen GAE and Python, you can specify options to the deferred call like this:

    retry = taskqueue.TaskRetryOptions(task_retry_limit=0)
    deferred.defer(..., _retry_options=retry)
    

    This will prevent the task from being retried.

    If you are using second gen GAE, please update your question to indicate that.