Celery Received unregistered task of type (run example)

后端 未结 30 1842
旧时难觅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 04:58

    I also had the same problem; I added

    CELERY_IMPORTS=("mytasks")
    

    in my celeryconfig.py file to solve it.

    0 讨论(0)
  • 2020-11-28 04:59
    app = Celery('proj',
                 broker='amqp://',
                 backend='amqp://',
                 include=['proj.tasks'])
    

    please include=['proj.tasks'] You need go to the top dir, then exec this

    celery -A app.celery_module.celeryapp worker --loglevel=info
    

    not

    celery -A celeryapp worker --loglevel=info
    

    in your celeryconfig.py input imports = ("path.ptah.tasks",)

    please in other module invoke task!!!!!!!!

    0 讨论(0)
  • 2020-11-28 04:59

    I had the issue with PeriodicTask classes in django-celery, while their names showed up fine when starting the celery worker every execution triggered:

    KeyError: u'my_app.tasks.run'

    My task was a class named 'CleanUp', not just a method called 'run'.

    When I checked table 'djcelery_periodictask' I saw outdated entries and deleting them fixed the issue.

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

    Write the correct path to the file tasks

    app.conf.beat_schedule = {
    'send-task': {
        'task': 'appdir.tasks.testapp',
        'schedule': crontab(minute='*/5'),  
    },
    

    }

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

    What worked for me, was to add explicit name to celery task decorator. I changed my task declaration from @app.tasks to @app.tasks(name='module.submodule.task')

    Here is an example

    # test_task.py
    @celery.task
    def test_task():
        print("Celery Task  !!!!")
    
    # test_task.py
    @celery.task(name='tasks.test.test_task')
    def test_task():
        print("Celery Task  !!!!")
    
    0 讨论(0)
  • 2020-11-28 05:04

    If you are using the apps config in installed apps like this:

    LOCAL_APPS = [
    'apps.myapp.apps.MyAppConfig']
    

    Then in your config app, import the task in ready method like this:

    from django.apps import AppConfig
    
    class MyAppConfig(AppConfig):
        name = 'apps.myapp'
    
        def ready(self):
            try:
                import apps.myapp.signals  # noqa F401
                import apps.myapp.tasks
            except ImportError:
                pass
    
    0 讨论(0)
提交回复
热议问题