title: Create class based Celery task for reusable app in Django project
body: <p>Creating function based task is quite clean for Django project. Just create tasks.py in django app and start writing task like this example which is taken from official celery documentation at <a href="http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html" rel="nofollow noreferrer">http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html</a> </p>
  
  <pre><code>from __future__ import absolute_import, unicode_literals
  from celery import shared_task
  
  @shared_task
  def add(x, y):
      return x + y
  
  
  @shared_task
  def mul(x, y):
      return x * y
  </code></pre>
  
  <p>But sometimes function based tasks are tightly coupled and not very reusable. So i wanted to create class based celery task which is documented in official site. After following <a href="https://github.com/celery/celery/issues/3874" rel="nofollow noreferrer">https://github.com/celery/celery/issues/3874</a> I could create sample task but I am not sure if its proper way to create class based task.  </p>
  
  <pre><code>from __future__ import absolute_import, unicode_literals
  from celery import shared_task, Task
  import time
  from celery import current_app
  
  
  @shared_task
  def add(x, y):
      time.sleep(5)
      return x + y
  
  
  @shared_task
  def mul(x, y):
      return x * y
  
  # Sample class based task for testing
  class AnotherTask(current_app.Task):
      name = 'tasks.another_task'
      def __init__(self, x, y):
          self.x = x
          self.y = y
  
      def run(self):
          time.sleep(5)
          return self.x + self.y
  # We need to manually register this class based task    
  current_app.tasks.register(AnotherTask(3, 4))
  </code></pre>
  
  <p>I am able to call this task but each call result value is same</p>
  
  <pre><code>(workflow) alok@alok-MacBookAir:~/exp/expdjango/mysite$ ./manage.py shell
  Python 3.6.3 (default, Oct  3 2017, 21:45:48) 
  Type "copyright", "credits" or "license" for more information.
  
  IPython 5.1.0 -- An enhanced Interactive Python.
  ?         -&gt; Introduction and overview of IPython's features.
  %quickref -&gt; Quick reference.
  help      -&gt; Python's own help system.
  object?   -&gt; Details about 'object', use 'object??' for extra details.
  
  In [1]: from polls.tasks import *
  
  In [2]: r = AnotherTask(3,4).delay()
  
  In [3]: r.get()
  Out[3]: 7
  
  In [4]: r = AnotherTask(5,6).delay()
  
  In [5]: r.get()
  Out[5]: 7
  </code></pre>
  
  <p>Is it a proper way to create and call class based task?</p>