高远介绍的好东东--django-celery

时间:2023-12-24 13:02:37

终于可以到异步消息机制的高档产品啦~~~

不知能不能代替AJAX。。

参照官方文档试下:

中文文档:

http://docs.jinkan.org/docs/celery/getting-started/brokers/rabbitmq.html

http://docs.celeryproject.org/en/2.5/django/first-steps-with-django.html

tasks.py

from celery import task

@task()
def add(x, y):
    return x + y

settings.py可以这样配(用DJANGO的库):

import djcelery

djcelery.setup_loader()
BROKER_URL = 'django://'

.....

# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    .....

    'djcelery',
    'celerytest',
    'kombu.transport.django',
)

高远介绍的好东东--django-celery