我已经按照以下方式配置芹菜以使用json:
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
但是,当工作人员收到任务时,会产生以下错误:
ContentDisallowed: Refusing to deserialize untrusted content of type pickle (application/x-python-serialize)
是否有一些我遗漏的东西可能没有记录。
答案 0 :(得分:2)
问题是芹菜接受为json
,并且在发送任务时其发送内容为pickle
,因此出错。
如here所述,您在通话时必须指定序列化程序(自celery 4.0起默认为json
)
add.apply_async((10, 10), serializer='json')
答案 1 :(得分:-1)