pip install celery
Download RabbitMQ.exe file to inatll(need Erlang installed first) (Windwos)
celery configure:
In my setting file,add:
CELERY_BROKER_URL = 'amqp://localhost' #Redis also surpported
In my project directory,New a file named celery,py,code as:
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'smartSdy.settings')
app = Celery('smartSdy')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
At last, In my app (quiz) folder, new a file named tasks.py,(tasks will list in this file to be executed by celery backend )
example code:
from celery import shared_task
@shared_task
def heavyTask():
//your code
check in terminal:
when "celery Task handler raised error: ValueError('not enough values to unpack...." error occured(in wondows),
May be you could install eventlet ,
pip install eventlet
then
celery -A smartSdy worker -l info -P eventlet [Windows]
celery -A smartSdy worker -l info [Linux]
pip install celery Download RabbitMQ.exe file to inatll(need Erlang installed first) (Windwos) celery configure: In my setting file,add:
CELERY_BROKER_URL = 'amqp://localhost' #Redis also surpported
In my project directory,New a file named celery,py,code as:
At last, In my app (quiz) folder, new a file named tasks.py,(tasks will list in this file to be executed by celery backend ) example code:
check in terminal:
when "celery Task handler raised error: ValueError('not enough values to unpack...." error occured(in wondows), May be you could install eventlet , pip install eventlet
then
celery -A smartSdy worker -l info -P eventlet
[Windows]celery -A smartSdy worker -l info
[Linux]