Inadmissible error in the content of celery weeds

Even if I have the following lines in settings.py:

CELERY_ACCEPT_CONTENT = ['application/json'] CELERY_TASKS_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' from kombu import serialization serialization.registry._decoders.pop("application/x-python-serialize") 

I still get inappropriate trace content. It’s strange that I already have celery working perfectly with exactly the same settings elsewhere. If anyone could offer a solution, that would be very helpful. Django's version is 1.7.1, and celery was downloaded today, so it should be the last. Using rabbitmq as a broker. The following is a complete error trace.

 [2015-01-01 23:45:20,652: CRITICAL/MainProcess] Can't decode message body: ContentDisallowed('Refusing to deserialize untrusted content of type pickle (application/x-python-serialize)',) [type:u'application/x-python-serialize' encoding:u'binary' headers:{}] body: '\x80\x02}q\x01(U\x07expiresq\x02NU\x03utcq\x03\x88U\x04argsq\x04X\x04\x00\x00\x00dsgfq\x05\x85q\x06U\x05chordq\x07NU\tcallbacksq\x08NU\x08errbacksq\tNU\x07tasksetq\nNU\x02idq\x0bU$76263889-0ef2-4193-8286-1a38630df08aq\x0cU\x07retriesq\rK\x00U\x04taskq\x0eU"pricematch.tasks.amazon_pricematchq\x0fU\ttimelimitq\x10NN\x86U\x03etaq\x11NU\x06kwargsq\x12}q\x13u.' (241b) Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/kombu/messaging.py", line 586, in _receive_callback decoded = None if on_m else message.decode() File "/usr/local/lib/python2.7/dist-packages/kombu/message.py", line 142, in decode self.content_encoding, accept=self.accept) File "/usr/local/lib/python2.7/dist-packages/kombu/serialization.py", line 174, in loads raise self._for_untrusted_content(content_type, 'untrusted') ContentDisallowed: Refusing to deserialize untrusted content of type pickle (application/x-python-serialize) 

This is what I have in the celery.py file in the project directory, parallel to the settings.py file:

 from __future__ import absolute_import import os from celery import Celery from django.conf import settings os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'projectname.settings') app = Celery('projectname',broker='amqp://',backend='amqp://',) app.config_from_object('django.conf:settings') app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) @app.task(bind=True) def debug_task(self): print('Request: {0!r}'.format(self.request)) 

Please let me know if more information is needed.

+6
source share
1 answer

I believe what you are looking for

 CELERY_TASK_SERIALIZER 

but not

 CELERY_TASKS_SERIALIZER 

celery-task-serializer

+7
source

Source: https://habr.com/ru/post/980416/


All Articles