环境描述python
python2+django1.9下使用celery异步处理耗时请求。
celery使用的是celery-with-redis这个第三方库,版本号为3.0。git
pip install celery-with-redis
这样安装会将redis、celery-with-redis、redis等一块儿同时安装。github
错误描述redis
错误提示:Unrecoverable error: AttributeError("'unicode' object has no attribute 'iteritems')django
问题发现及解决bash
将这个错误Google后,在stackoverflow中发现了解决办法,地址:stack overflow,celery-github
问题的症结是redis的版本号为3.0以上,致使celery将其做为消息中间件的时候出现问题,给出的解决方案是安装3.0如下的redis版本。这里咱们安装redis==2.10.6异步
pip uninstall redis
pip install redis==2.10.6
celery worker -A xxx -l INFO