Am having problems running tasks when setup as class methods. I've read about celery.contrib.methods from the answer here on SO but am not able to apply it to my case.
celery_conf.celeryapp.py
from __future__ import absolute_import
from celery import Celery
app = Celery()
app.config_from_object('celery_conf.celeryconfig')
if __name__ == '__main__':
app.start()
celery_conf.celeryconfig.py
BROKER_URL = 'amqp://'
CELERY_RESULT_BACKEND = 'amqp://'
CELERY_TASK_RESULT_EXPIRES = 3600
CELERY_AMQP_TASK_RESULT_EXPIRES = 60
CELERYD_PREFETCH_MULTIPLIER = 0
CELERY_IMPORTS=("student.process_records")
student.process_records.py
from celery_conf.celeryapp import app
from celery.contrib.methods import task_method
class Student():
'''student class'''
@app.task(filter=task_method, name='student.process_records.get_student_id')
def get_student_id(self, **kwargs):
'''process some student ids'''
def main():
student = Student()
student.get_student_id.delay(**task_to_do)
if __name__ == '__main__':
main()
With the above configuration, I keep getting the errors
[2014-10-29 20:38:02,073: CRITICAL/MainProcess] Can't decode message body: DecodeError(AttributeError("Can't get attribute 'Student' on <module 'celery.bin.celery' from '/home/lukik/venv/python_3_4/lib/python3.4/site-packages/celery/bin/celery.py'>",),) [type:'application/x-python-serialize' encoding:'binary' headers:{}]
kombu.exceptions.DecodeError: Can't get attribute 'Student' on <module 'celery.bin.celery' from '/home/lukik/venv/python3_4/lib/python3.4/site-packages/celery/bin/celery.py'>
How should I configure or import items in order for it to work?
celery_version = 3.1.16
python_version = python3.4