Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force celery to use json in place of pickle

Tags:

python

celery

I've configured celery to use json in the following manner:

CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'

However, when the worker receives the task it generates the following error:

ContentDisallowed: Refusing to deserialize untrusted content of type pickle (application/x-python-serialize)

Is there something I am missing that's undocumented perhaps.

like image 204
Lloyd Moore Avatar asked Apr 28 '16 15:04

Lloyd Moore


1 Answers

The problem is celery is accepting as json and while sending a task its sending content as pickle hence the error.

As mentioned here while calling you will have to specify serializer ( which is json by default since celery 4.0 )

add.apply_async((10, 10), serializer='json') 
like image 148
bak2trak Avatar answered Oct 01 '22 03:10

bak2trak