我刚刚设置了第一个 Celery 实例,但出于安全考虑,我收到了禁用 pickle 作为序列化程序的警告。关闭它的后果是什么? Celery 需要序列化器做什么?
If you depend on pickle then you should set a setting to disable this warning and to be sure that everything will continue working when you upgrade to Celery 3.2::
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
最佳答案
来自 http://celery.readthedocs.org/en/latest/faq.html#is-celery-dependent-on-pickle :
The default serialization format is pickle simply because it is convenient (it supports sending complex Python objects as task arguments).
无论您是否使用 pickle,您都可能希望通过设置 CELERY_ACCEPT_CONTENT
配置变量来关闭此警告。
如果您不使用 Python 对象作为任务中的参数,您应该考虑使用安全的方法,例如json序列化格式。
pickle 的另一个限制是没有任务结果 - 参见 http://docs.celeryproject.org/en/latest/faq.html#isn-t-using-pickle-a-security-concern :
For the task messages you can set the CELERY_TASK_SERIALIZER setting to “json” or “yaml” instead of pickle. There is currently no alternative solution for task results (but writing a custom result backend using JSON is a simple task)
关于python - celery 会默认拒绝接受 pickle ,我应该禁用它吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22889269/