복붙노트

[REDIS] 유형의 오류가 수신 등록 작업을 받고 'mytasks.add'

REDIS

유형의 오류가 수신 등록 작업을 받고 'mytasks.add'

나는 파일 mytasks.py을 작성했습니다

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)

나는 레디 스 서버를 시작하고 난 셀러리 서버를 시작했습니다. 내가 다음 task.py 실행 해요 그러나 나는 다음과 같은 오류를 얻고있다 :

    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'

가능한 이유는 어떻게 될 것인가

해결법

  1. ==============================

    1.이봐, 난이 문제를 해결했다 내가 추가 한 일을했다

    이봐, 난이 문제를 해결했다 내가 추가 한 일을했다

    CELERY_IMPORTS=("mytasks")
    

    내 celeryconfig.py 파일과 내가 성공 얻었다.

  2. ==============================

    2.http://docs.celeryproject.org/en/latest/getting-started/next-steps.html#proj-celery-py : 또한 셀러리 클래스의 PARAM을 포함 사용할 수 있습니다

    http://docs.celeryproject.org/en/latest/getting-started/next-steps.html#proj-celery-py : 또한 셀러리 클래스의 PARAM을 포함 사용할 수 있습니다

  3. from https://stackoverflow.com/questions/12108639/getting-error-received-unregistered-task-of-type-mytasks-add by cc-by-sa and MIT license