I have some of the analytics methods in models.py
under class Analytics
(e.g: Analytics.record_read_analytics()
). And we are calling those methods for recording analytics, which doesn't need to be synchronous. Currently it's affecting rendering of each request so decided to add these methods in celery queue. We are already using celery for some of our tasks hence we have tasks.py
and celery.py
file.
Following is section of models.py
file:
class Analytics():
...
...
@staticmethod
def method_a():
...
...
def method_b():
...
...
@staticmethod
def record_read_analytics():
...
...
I don't wanted to write again same model level class methods in tasks.py
and wanted to make some of view method's and model level class methods as celery task.
Following is celery.py
file:
from __future__ import absolute_import
from celery import Celery
app = Celery('gnowsys_ndf',
include=['gnowsys_ndf.tasks'])
app.config_from_object('gnowsys_ndf.celeryconfig')
if __name__ == '__main__':
app.start()
I'm new to celery
and looking for help. Thank you in advance.