0

I am using django, celery and RabbitMQ for a webserver. On my development server everything works fine. However, when I try to run the webserver on my production server with apache2/mod_wsgi every second time I reload the result page I get the following error: 'DisabledBackend' object has no attribute '_get_task_meta_for'

That happens when I try to run the following command:

task_state = <taskname>.AsyncResult(task_id).state

My CeleryConfiguration is as following:

app = Celery('<name>',
             broker='amqp://<user>:' + RABBITMQ_PASSWD + '@localhost:5672/<vhost>',
             backend='django-db',
             task_ignore_result=False,
             task_track_started=True,
            )

The backend is set and it works exactly every second time. I tried restarting the services, the computer and cleaning the databases. Same problem with different backends. Does anyone have an idea what could cause the problem?

Thank you for your help!

Edit: I already looked at the solutions here: Celery with RabbitMQ: AttributeError: 'DisabledBackend' object has no attribute '_get_task_meta_for' but I don't think my problem has anything to do with the django setup. On my development server I don't experience any problems. Only on my production server the backend gets "lost" every second time. If I press then reload after I see the error, the webpage is shown correctly. If I press again reload the error is shown again. But I cannot find any reasons. I searched the rabbitmq logs, the apache logs, celery logs but I am not able to identify the reason.

Edit 2: After some more testing, it seems to me that the problem is somehow the apache2/wsgi, because everything works if I use the production server together with the normal celery setup. Only when I switch then to apache/mod_wsgi the error occurs.

Edit 3: The problem is caused by using the WSGIDeaemonprocess as recommended here: https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/modwsgi/. My configuration in virtualhost look like this:

WSGIScriptAlias / <path>/wsgi.py
WSGIDaemonProcess <name> python-home=<path to virtualenv> python-path=<path to django project>
WSGIProcessGroup <name>
WSGIApplicationGroup %{GLOBAL}

I then get the error every second reload. However when I remove these lines and use the following lines outside of the virtualhost configuration, everything is working:

WSGIScriptAlias /  <path>/wsgi.py
WSGIPythonHome <path to virtualenv>
WSGIPythonPath <path to django project>
Carsten
  • 1
  • 2
  • Does this answer your question? [Celery with RabbitMQ: AttributeError: 'DisabledBackend' object has no attribute '\_get\_task\_meta\_for'](https://stackoverflow.com/questions/23215311/celery-with-rabbitmq-attributeerror-disabledbackend-object-has-no-attribute) – mehrdadep May 19 '21 at 16:09
  • @MehrdadEP Unfortunately not. I had a look at it before but the solutions don't work for me. I think my problem is different because it does generally work on my development server but it only works 50% of the time on my production server. – Carsten May 20 '21 at 06:35
  • Having a similar issue with Flask and Redis doing local testes. First request fails with DisabledBackend, seconds request works. The worker still finds the test from the queue and executes it, and saves the result in the backend (same as the queue), but still get the error. – lowercase00 Aug 20 '21 at 15:37

0 Answers0