启动 celery worker 报错:AttributeError: 'str' object has no attribute 'items'

2023-02-18 13:38:09 浏览数 (2)

错误日志

代码语言:javascript复制
(joyoo) yinzhuoqundeMacBook-Pro:joyoo yinzhuoqun$ python manage.py celery worker --loglevel=info
raven.contrib.django.client.DjangoClient: 2019-12-15 02:07:00,997 /Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/raven/base.py [line:213] INFO Raven is not configured (logging is disabled). Please see the documentation for more information.

-------------- celery@yinzhuoqundeMacBook-Pro.local v3.1.26.post2 (Cipater)
---- **** ----- 
--- * ***  * -- Darwin-18.6.0-x86_64-i386-64bit
-- * - **** --- 
- ** ---------- [config]
- ** ---------- .> app:         default:0x10ee9be48 (djcelery.loaders.DjangoLoader)
- ** ---------- .> transport:   redis://127.0.0.1:6379/0
- ** ---------- .> results:     
- *** --- * --- .> concurrency: 12 (prefork)
-- ******* ---- 
--- ***** ----- [queues]
 -------------- .> celery           exchange=celery(direct) key=celery

                
[tasks]
  . blog.tasks.dd_text_post

[2019-12-15 02:07:01,631: INFO/MainProcess] Connected to redis://127.0.0.1:6379/0
[2019-12-15 02:07:01,641: INFO/MainProcess] mingle: searching for neighbors
[2019-12-15 02:07:02,650: INFO/MainProcess] mingle: all alone
[2019-12-15 02:07:02,660: WARNING/MainProcess] /Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/djcelery/loaders.py:133: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
  warn('Using settings.DEBUG leads to a memory leak, never '
[2019-12-15 02:07:02,660: WARNING/MainProcess] celery@yinzhuoqundeMacBook-Pro.local ready.
®
[2019-12-15 02:14:15,435: ERROR/MainProcess] Unrecoverable error: AttributeError("'str' object has no attribute 'items'",)
Traceback (most recent call last):
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/celery/worker/__init__.py", line 206, in start
    self.blueprint.start(self)
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/celery/bootsteps.py", line 123, in start
    step.start(parent)
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/celery/bootsteps.py", line 374, in start
    return self.obj.start()
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/celery/worker/consumer.py", line 280, in start
    blueprint.start(self)
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/celery/bootsteps.py", line 123, in start
    step.start(parent)
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/celery/worker/consumer.py", line 884, in start
    c.loop(*c.loop_args())
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/celery/worker/loops.py", line 76, in asynloop
    next(loop)
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/kombu/async/hub.py", line 340, in create_loop
    cb(*cbargs)
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/kombu/transport/redis.py", line 1019, in on_readable
    self._callbacks[queue](message)
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/kombu/transport/virtual/__init__.py", line 534, in _callback
    self.qos.append(message, message.delivery_tag)
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/kombu/transport/redis.py", line 146, in append
    pipe.zadd(self.unacked_index_key, delivery_tag, time()) 
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/redis/client.py", line 2388, in zadd
    def execute_command(self, *args, **kwargs):
  File "/Users/yinzhuoqun/.pyenv/joyoo/lib/python3.6/site-packages/redis/_compat.py", line 161, in iteritems
AttributeError: 'str' object has no attribute 'items'

解决办法

降低 redis 版本

pip install redis==2.10.6

0 人点赞