2016-05-14 7 views
2

セロリーを初めて使い、アプリで使ってみようとしていました。以下は私の基本的なアプリの構造ですセロリーは「登録されていないタスクを受け取りました」

自分のタスクのすべてのタスクを自分のタスクモジュールに限定したいと思います。タスクののinitの.pyでは私は私の仕事の中

from celery import Celery 

celery = Celery('my_app', broker='redis://localhost:6379/0') 

を持っている/メール私は

celery -A app.tasks worker --loglevel=DEBUG 

しかし、私のタスクを使用して、ワーカーを開始し、端末から

from app.tasks import celery 

@celery.task 
def send_email(): 
    #do stuff 

を持っていますセロリのタスクリストには表示されません。私はこれを行うとそう

>>from app.tasks import email 
>>email_result = email.send_email.delay() 

私は私のセロリ端子

Received unregistered task of type 'app.tasks.emails.send_email'. 
The message has been ignored and discarded. 

Did you remember to import the module containing this task? 
Or maybe you are using relative imports? 
Please see url for more information. 

The full contents of the message body was: 
{'kwargs': {}, 'taskset': None, 'id': '51e8f766-e772-4d85-bad0-5a6774ea541a', 'eta': None, 'timelimit': (None, None), 'args': [], 'retries': 0, 'task': 'app.tasks.emails.send_email', 'utc': True, 'errbacks': None, 'chord': None, 'expires': None, 'callbacks': None} (283b) 
Traceback (most recent call last): 
File "/usr/local/lib/python3.4/site-packages/celery/app/utils.py", line 235, in find_app 
sym = symbol_by_name(app, imp=imp) 
File "/usr/local/lib/python3.4/site-packages/celery/bin/base.py", line 492, in symbol_by_name 
return symbol_by_name(name, imp=imp) 
File "/usr/local/lib/python3.4/site-packages/kombu/utils/__init__.py", line 101, in symbol_by_name 
return getattr(module, cls_name) if cls_name else module 
AttributeError: 'module' object has no attribute 'tasks' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
File "/usr/local/lib/python3.4/site-packages/celery/worker/consumer.py", line 456, in on_task_received 
strategies[name](message, body, 
KeyError: 'app.tasks.channels.send_email' 

で、次の応答を得るように私は通訳から私のタスクを実行した後も、私は、Python 3.4とセロリ3.1.23

を使用しています

答えて

13

誰かがそれを必要とするならば、ついにそれを働かせました。 私は何を必要とするタスク登録するセロリのための順序どおりのタスクを含む実際のファイルのためのセロリワーカー実行されました - 単に

celery -A app.tasks worker --loglevel=DEBUG 

を実行しているので、(これは私の野生の推測です)

celery -A app.tasks.emails worker --loglevel=DEBUG 

を実際に私のsend_email()タスクをインポートすることはありません。誰かが私に説明を与えることができる場合はこれをしてください。

関連する問題