title: How to get Django-Q to send a message once the broker has finished executing a task?
body: <p>I have a django app that needs to send some big tasks to the backend to execute aysnchronously.  I'm using django-q with redis for this.</p>
  
  <p>It works at a basic level - the task is sent to redis, django is no longer blocked waiting - but it does it silently. The app doesn't know when the task is complete, or if it has completed successfully.  This makes it really brittle. I'm now trying to get a signal back from redis when the task is complete (successfully or not).</p>
  
  <p>Looking at the DjangoQ <a href="https://django-q.readthedocs.io/en/latest/tasks.html" rel="nofollow noreferrer">documentation</a>, I've set up the following proof of concept:</p>
  
  <p><em>views.py</em></p>
  
  <pre><code>import json
  from django.http import JsonResponse
  from django_q_tasks import async_task
  
  def testredisview(request):
      json_payload = {"message": "hello world!"}
      async_task("services.sleep_and_print", 10, hook='hooks.print_result')
      return JsonResponse(json_payload)
  </code></pre>
  
  <p><em>services.py</em></p>
  
  <pre><code>from time import sleep
  
  def sleep_and_print(secs):
      sleep(secs)
      print("task done")
  
  </code></pre>
  
  <p><em>hooks.py</em></p>
  
  <pre><code>def print_result(task):
      print((task.id, task.result))
  </code></pre>
  
  <p>When I run <code>python3 manage.py qcluster</code> and then hit the url <code>127.0.0.1:8000/testredis</code>, 10 seconds later I get the JSON: <code>message: "hello world!"</code>  and the django server shows: <code>[Q] INFO Enqueued 1</code>, so it's executing the service command successfully.</p>
  
  <p>However, the cluster shows: </p>
  
  <pre><code>[Q] INFO Q Cluster -cluster_name- running.
  [Q] INFO Process-1:1 processing [-process_name-]
  'task done'
  '(-task_id-, None)'
  [Q] INFO Processed [-process_name-]
  </code></pre>
  
  <p>The documentation states that <code>task.result = None</code> means that task hasn't been executed, and that <code>hook</code> is called after the task has been executed, so I would have expected a result object to be returned, instead of <code>None</code></p>
  
  <p>I've tried enforcing synchronicity (<code>Q_CLUSTER['sync']=True</code>) but have the same results.</p>