title: Recover from task failed beyond max_retries
body: <p>I am attempting to asynchronously consume a web service because it takes up to 45 seconds to return.  Unfortunately, this web service is also somewhat unreliable and can throw errors.  I have set up <code>django-celery</code> and have my tasks executing, which works fine until the task fails beyond <code>max_retries</code>.  </p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>@task(default_retry_delay=5, max_retries=10)
  def request(xml):
      try:
          server = Client('https://www.whatever.net/RealTimeService.asmx?wsdl')
          xml = server.service.RunRealTimeXML(
              username=settings.WS_USERNAME,
              password=settings.WS_PASSWORD,
              xml=xml
          )
      except Exception, e:
          result = Result(celery_id=request.request.id, details=e.reason, status="i")
          result.save()
          try:
              return request.retry(exc=e)
          except MaxRetriesExceededError, e:
              result = Result(celery_id=request.request.id, details="Max Retries Exceeded", status="f")
              result.save()
              raise
      result = Result(celery_id=request.request.id, details=xml, status="s")
      result.save()
      return result
  </code></pre>
  
  <p>Unfortunately, <code>MaxRetriesExceededError</code> is not being thrown by <code>retry()</code>, so I'm not sure how to handle the failure of this task.  Django has already returned HTML to the client, and I am checking the contents of <code>Result</code> via AJAX, which is never getting to a full fail <code>f</code> status. </p>
  
  <p>So the question is:  How can I update my database when the Celery task has exceeded <code>max_retries</code>?</p>