title: Proper design pattern for 202 Accepted responses
body: <p>I have a celery <code>shared_task</code> setup to retry up to 10 times if it doesn't succeed the first time. The initial log statement is only executed once. None of the exceptions ever get raised nor does the embedded <code>try/else</code>. The statement <code>result = LdapHostGroupView().start(data, username, version)</code> does execute and it shows from log entries that it succeeded, but the final <code>else</code> never executes.</p>
  
  <p>What's going on here?</p>
  
  <pre><code>@shared_task(bind=True, default_retry_delay=15, max_retry=10)
  def host_accepted(self, data, username, version):
      from .api.views import LdapHostGroupView
      name = data.get('name', '')
      version = Decimal(version)
      log.debug("name: %s, version: %s, version type: %s, data: %s",
                name, version, type(version), data)
  
      try:
          obj = Transaction.objects.get(endpoint_name=name)
      except Transaction.DoesNotExist as e:
          msg = "Could not find transaction '{}'".format(name)
          log.critical(msg)
          syslog.critical(msg)
      else:
          try:
              result = LdapHostGroupView().start(data, username, version)
          except RealmBundleDoesNotExist as e:
              log.debug("Bundle does not exist yet.")
              obj.job_summary += str(e) + '\n'
              obj.job_status = Transaction.INPROGRESS
              obj.save()
              self.retry(exc=e) # ** self.request.retries)
          except (RealmCriticalException, ValidationError) as e:
              error = e.get_full_details()
              log.debug("Host Accepted error: %s", error)
  
              if isinstance(error, dict):
                  for field, values in error.items():
                      for value in values:
                          ed = value.get('message')
  
                          if isinstance(ed, ErrorDetail):
                              item = str(ed)
                          else:
                              item = value
  
                          msg = "Field '{}' has error: {}\n".format(field, item)
                          obj.job_summary += msg
              else:
                  obj.job_summary += "Had error with no message.\n"
  
              obj.job_status = Transaction.FAILURE
              obj.save()
          else:
              log.info("Celery task 'host_accepted' executed at %s, "
                       "returned %s, incoming data %s",
                       datetime.now(tzutc()).isoformat(), result, data)
  
              # Check the result object.
  
              obj.job_status = Transaction.SUCCESS
              obj.save()
  </code></pre>
  
  <p>it is called in the Django view like this:</p>
  
  <pre><code>   host_accepted.delay(request.data, request.user.username, request.version)
  </code></pre>