0

I am using a GAE push Task Queue. I want the task to run once and if it fails I want it to notify me somehow. I also don't want it to do any retries. If it fails I want it to sit in the queue until I rerun it manually.

I can manually catch all exceptions and send an email to myself it it fails. Is there a better way? In the queue config I can specify retry limit (see below) of zero but if I do this the task is deleted as soon as it fails.

# queue.yaml
- name: default
  rate: 5/s
  retry_parameters:
    task_retry_limit: 0

Any ideas?

guneysus
  • 6,203
  • 2
  • 45
  • 47
goody44
  • 128
  • 1
  • 7

4 Answers4

5

When a task retries, you can read the retry count in next retry. And do what you need to do.

Look here for : 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.

voscausa
  • 11,253
  • 2
  • 39
  • 67
3

The only way I can think of to accomplish this would be to set a high value for min_backoff_seconds. If you can set that for something high like 7 days, then that should give you enough time to take action in response to your email message.

I don't know if there is a limit to how high a value you can set for min_backoff_seconds so you'll want to check that.

I think catching exceptions and sending yourself an email is the only way to notify yourself of a task failure.

new name
  • 15,861
  • 19
  • 68
  • 114
0

I don't think of any way to do what you want besides grabbing all exceptions. GAE won't send a message when a taskqueue fails, there is no service to "allow" to get that functionality unfortunately.

Unless you get a Google Engineer to answer something about a service I'm not aware of....

Patrice
  • 4,641
  • 9
  • 33
  • 43
0

@voscausa's answer means that: you can implement a taskCheckerTask that always returns http codes any number except between 200-299. But do not forget task will be deleted from queue if it fails.

class TaskChecker(webapp2.RequestHandler):
    def post(self):
        # Check tasks and retries here
        # If need send mail
        self.echo(500)
guneysus
  • 6,203
  • 2
  • 45
  • 47