python - celery 会默认拒绝接受 pickle ,我应该禁用它吗?

标签 python django celery pickle

我刚刚设置了第一个 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/

相关文章:

python - 如何禁用 Django Celery 管理模块?

python - 为什么 Celery 对 Redis 代理使用轮询?

python - 如何对不同长度的 numpy 数组进行子集化

python - 当刻度标签位于顶部时,Seaborn 热图 xticklabels 水平对齐不起作用

python - Django操作错误 'no such column:' sqlite

html - 如何在html中显示本地时间?

python - Django 模型在模板中不可迭代

python - 在 while 循环中处理异常

python - 我怎样才能更快地阅读一行?

python - Celery:何时何地使用运行@task 的.delay() 的返回值来更新数据库?