2012-08-24 11 views
10

प्रकार के अपंजीकृत कार्य प्राप्त मैं एक फ़ाइल mytasks.pyहो रही त्रुटि 'mytasks.add'

from celery import Celery 

celery = Celery("tasks", 
       broker='redis://localhost:6379/0', 
       backend='redis') 


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

और task.py के रूप में पालन

from mytasks import add 

add.delay(1,1) 

मैं शुरू कर दिया है redis सर्वर लिखा है और मैं अजवाइन सर्वर शुरू कर दिया है । लेकिन जब task.py तो चल रहा im मैं निम्न त्रुटि हो रही है:

Received unregistered task of type 'mytasks.add'. 
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 http://bit.ly/gLye1c for more information. 

The full contents of the message body was: 
{'retries': 0, 'task': 'mytasks.add', 'eta': None, 'args': (1, 1), 'expires': None, 'callbacks': None, 'errbacks': None, 'kwargs': {}, 'id': 'a4792308-d575-4de4-8b67-26982cae2fa4', 'utc': True} (173b) 

Traceback (most recent call last): 
    File "/usr/local/lib/python2.7/dist-packages/celery/worker/consumer.py", line 411, in on_task_received 
    strategies[name](message, body, message.ack_log_error) 
KeyError: 'mytasks.add' 

क्या possibel कारण

उत्तर

13

अरे मैं इस समस्या समाधान कर लिया है हो सकता है मैं एक बात मैं जोड़ना था

CELERY_IMPORTS=("mytasks") 

मेरी celeryconfig.py फ़ाइल में और मैं सफल हो गया।

+0

धन्यवाद, मुझे – Anentropic

+0

यह मेरे लिए भी काम करता है के लिए काम किया :) –