Celery with RabbitMQ: AttributeError: 'DisabledBackend' object has no attribute '_get_task_meta_for'

前端 未结 5 695
Happy的楠姐
Happy的楠姐 2020-12-08 18:13

I\'m running the First Steps with Celery Tutorial.

We define the following task:

from celery import Celery

app = Celery(\'tasks\', broker=\'amqp://g         


        
相关标签:
5条回答
  • 2020-12-08 18:45

    in your project directory find the settings file.

    then: sudo vim settings.py copy/paste into settings.py: CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend'

    note: this is if you are using django-celery as the backend for storing the messages in the queue.

    0 讨论(0)
  • 2020-12-08 18:46

    I suggest having a look at: http://www.cnblogs.com/fangwenyu/p/3625830.html

    There you will see that instead of

    app = Celery('tasks', broker='amqp://guest@localhost//')
    

    you should be writing

    app = Celery('tasks', backend='amqp', broker='amqp://guest@localhost//')
    

    This is it.

    0 讨论(0)
  • 2020-12-08 18:51

    In case anyone made the same easy to make mistake as I did: The tutorial doesn't say so explicitly, but the line

    app = Celery('tasks', backend='rpc://', broker='amqp://')
    

    is an EDIT of the line in your tasks.py file. Mine now reads:

    app = Celery('tasks', backend='rpc://', broker='amqp://guest@localhost//')
    

    When I run python from the command line I get:

    $ python
    >>> from tasks import add
    >>> result = add.delay(4,50)
    >>> result.ready()
    >>> False
    

    All tutorials should be easy to follow, even when a little drunk. So far this one doesn't reach that bar.

    0 讨论(0)
  • 2020-12-08 18:53

    Just keep reading tutorial. It will be explained in Keep Results chapter.

    To start Celery you need to provide just broker parameter, which is required to send messages about tasks. If you want to retrieve information about state and results returned by finished tasks you need to set backend parameter. You can find full list with description in Configuration docs: CELERY_RESULT_BACKEND.

    0 讨论(0)
  • 2020-12-08 18:55

    What is not clear by the tutorial is that the tasks.py module needs to be edited so that you change the line:

    app = Celery('tasks', broker='pyamqp://guest@localhost//')
    

    to include the RPC result backend:

    app = Celery('tasks', backend='rpc://', broker='pyamqp://')
    

    Once done, Ctrl + C the celery worker process and restart it:

    celery -A tasks worker --loglevel=info
    

    The tutorial is confusing in that we're making the assumption that creation of the app object is done in the client testing session, which it is not.

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