celery:Unrecoverable error: AttributeError("'unicode' object has no attribute 'iteritems')

环境描述

python2+django1.9下使用celery异步处理耗时请求。
celery使用的是celery-with-redis这个第三方库,版本号为3.0。

pip install celery-with-redis

这样安装会将redis、celery-with-redis、redis等一起同时安装。

错误描述

错误提示:Unrecoverable error: AttributeError("'unicode' object has no attribute 'iteritems')

问题发现及解决

将这个错误Google后,在stackoverflow中发现了解决办法,地址:stack overflowcelery-github
问题的症结是redis的版本号为3.0以上,导致celery将其作为消息中间件的时候出现问题,给出的解决方案是安装3.0以下的redis版本。这里我们安装redis==2.10.6

  • 首先
pip uninstall redis
  • 其次
pip install redis==2.10.6
  • 最后
    重新运行celery即可。
celery worker -A xxx -l INFO
原文地址:https://www.cnblogs.com/cpl9412290130/p/10597291.html