芹菜和如何发送任务

时间:2014-01-26 15:39:42

标签: python celery

我发送的任务如下......

from celery import Celery
celery = Celery()
celery.send_task('order_celery.order_worker', (order,))

从工人日志......这就是我得到的......

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.7-py2.7.egg/celery/worker/consumer.py", line 445, in on_task_received
    strategies[name](message, body,
KeyError: 'order_celery.order_worker'

这是我的工人order_celery.py

from celery import Celery
app = Celery('tasks', broker='redis://%s:6379/0'%redis_host,backend='redis://%s:6379/0'%redis_host)

@app.task
def order_worker(order):
   return True

为什么芹菜不起作用?

1 个答案:

答案 0 :(得分:1)

order_celery.py应该在您的PYTHONPATH中,您应该像this一样运行您的工作人员:

celery -A order_worker worker --loglevel=info