我一直在尝试遵循Celery 与Celery和后续步骤指南的第一步.我的设置是Windows 7 64位,Anaconda Python 2.7(32位),安装的Erlang 32位二进制文件,RabbitMQ服务器和芹菜(带pip install celery).
在指南之后,我使用init .py,tasks.py和celery.py 创建了一个proj文件夹.我的init .py是空的.这是celery.py:
from __future__ import absolute_import
from celery import Celery
app = Celery('proj',
broker='amqp://',
backend='amqp://',
include=['proj.tasks'])
#Optional configuration, see the application user guide
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_TASK_SERIALIZER='json',
CELERY_ACCEPT_CONTENT=['json'], # Ignore other content
CELERY_RESULT_SERIALIZER='json',
)
if __name__ == '__main__':
app.start()
Run Code Online (Sandbox Code Playgroud)
这是task.py:
from __future__ import absolute_import
from .celery import app
@app.task
def add(x, y):
return x + y
@app.task
def mul(x, y):
return …Run Code Online (Sandbox Code Playgroud)