Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery pickle type content disallowed error

Even though I have 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 am still getting the pickle content disallowed traceback. Strange this is I already have celery working fine with exactly same settings in another place. If anyone could suggest a solution it would be really helpful. Django version is 1.7.1 and celery was downloaded today so should be latest. Using rabbitmq as broker. Following is the complete traceback of the error.

[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 celery.py file in project directory parallel to 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 additional info is needed

like image 843
Shark Avatar asked Jan 02 '15 00:01

Shark


1 Answers

I believe you're looking for

CELERY_TASK_SERIALIZER

and not

CELERY_TASKS_SERIALIZER

celery-task-serializer

like image 136
Ryan Serra Avatar answered Sep 19 '22 00:09

Ryan Serra