Celery Received unregistered task of type (run example)

后端 未结 30 1843
旧时难觅i
旧时难觅i 2020-11-28 04:42

I\'m trying to run example from Celery documentation.

I run: celeryd --loglevel=INFO

/usr/local/lib/python2.7/dist-packages/celery/loade         


        
相关标签:
30条回答
  • 2020-11-28 05:05

    I've found that one of our programmers added the following line to one of the imports:

    os.chdir(<path_to_a_local_folder>)
    

    This caused the Celery worker to change its working directory from the projects' default working directory (where it could find the tasks) to a different directory (where it couldn't find the tasks).

    After removing this line of code, all tasks were found and registered.

    0 讨论(0)
  • 2020-11-28 05:06

    Using --settings did not work for me. I had to use the following to get it all to work:

    celery --config=celeryconfig --loglevel=INFO
    

    Here is the celeryconfig file that has the CELERY_IMPORTS added:

    # Celery configuration file
    BROKER_URL = 'amqp://'
    CELERY_RESULT_BACKEND = 'amqp://'
    
    CELERY_TASK_SERIALIZER = 'json'
    CELERY_RESULT_SERIALIZER = 'json'
    CELERY_TIMEZONE = 'America/Los_Angeles'
    CELERY_ENABLE_UTC = True
    
    CELERY_IMPORTS = ("tasks",)
    

    My setup was a little bit more tricky because I'm using supervisor to launch celery as a daemon.

    0 讨论(0)
  • 2020-11-28 05:06

    when running the celery with "celery -A conf worker -l info" command all the tasks got listed in log like i was having . conf.celery.debug_task i was getting the error because I was not giving this exact task path. So kindly recheck this by copying and pasting exact task id.

    0 讨论(0)
  • 2020-11-28 05:07

    For me this error was solved by ensuring the app containing the tasks was included under django's INSTALLED_APPS setting.

    0 讨论(0)
  • 2020-11-28 05:07

    This, strangely, can also be because of a missing package. Run pip to install all necessary packages: pip install -r requirements.txt

    autodiscover_tasks wasn't picking up tasks that used missing packages.

    0 讨论(0)
  • 2020-11-28 05:09

    Just to add my two cents for my case with this error...

    My path is /vagrant/devops/test with app.py and __init__.py in it.

    When I run cd /vagrant/devops/ && celery worker -A test.app.celery --loglevel=info I am getting this error.

    But when I run it like cd /vagrant/devops/test && celery worker -A app.celery --loglevel=info everything is OK.

    0 讨论(0)
提交回复
热议问题