django celery AttributeError: 'str' object has no attribute 'items'

django celery 启动报错

(lion) F:\django\lion>celery -A lion worker -l info
[2019-03-26 09:12:17,582: WARNING/MainProcess] c:\anaconda3\envs\lion\lib\site-packages\celery\apps\worker.py:161: CDeprecationWarning:
Starting from version 3.2 Celery will refuse to accept pickle by default.

The pickle serializer is a security concern as it may give attackers
the ability to execute any command.  It's important to secure
your broker from unauthorized access when using pickle, so we think
that enabling pickle should require a deliberate action and not be
the default choice.

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']

You must only enable the serializers that you will actually use.


  warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))

 -------------- celery@DESKTOP-5BPL6EF v3.1.26.post2 (Cipater)
---- **** -----
--- * ***  * -- Windows-10-10.0.17763-SP0
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app:         lion:0x2a5bc625cc0
- ** ---------- .> transport:   redis://127.0.0.1:6379/1
- ** ---------- .> results:     redis://127.0.0.1:6379/2
- *** --- * --- .> concurrency: 12 (prefork)
-- ******* ----
--- ***** ----- [queues]
 -------------- .> celery           exchange=celery(direct) key=celery


[tasks]
  . app.tasks.check_order

[2019-03-26 09:12:17,726: INFO/MainProcess] Connected to redis://127.0.0.1:6379/1
[2019-03-26 09:12:17,726: INFO/MainProcess] mingle: searching for neighbors
[2019-03-26 09:12:18,729: INFO/MainProcess] mingle: all alone
[2019-03-26 09:12:18,767: WARNING/MainProcess] celery@DESKTOP-5BPL6EF ready.
[2019-03-26 09:12:19,064: ERROR/MainProcess] Unrecoverable error: AttributeError("'str' object has no attribute 'items'",)
Traceback (most recent call last):
  File "c:\anaconda3\envs\lion\lib\site-packages\celery\worker\__init__.py", line 206, in start
    self.blueprint.start(self)
  File "c:\anaconda3\envs\lion\lib\site-packages\celery\bootsteps.py", line 123, in start
    step.start(parent)
  File "c:\anaconda3\envs\lion\lib\site-packages\celery\bootsteps.py", line 374, in start
    return self.obj.start()
  File "c:\anaconda3\envs\lion\lib\site-packages\celery\worker\consumer.py", line 280, in start
    blueprint.start(self)
  File "c:\anaconda3\envs\lion\lib\site-packages\celery\bootsteps.py", line 123, in start
    step.start(parent)
  File "c:\anaconda3\envs\lion\lib\site-packages\celery\worker\consumer.py", line 884, in start
    c.loop(*c.loop_args())
  File "c:\anaconda3\envs\lion\lib\site-packages\celery\worker\loops.py", line 103, in synloop
    connection.drain_events(timeout=2.0)
  File "c:\anaconda3\envs\lion\lib\site-packages\kombu\connection.py", line 288, in drain_events
    return self.transport.drain_events(self.connection, **kwargs)
  File "c:\anaconda3\envs\lion\lib\site-packages\kombu\transport\virtual\__init__.py", line 847, in drain_events
    self._callbacks[queue](message)
  File "c:\anaconda3\envs\lion\lib\site-packages\kombu\transport\virtual\__init__.py", line 534, in _callback
    self.qos.append(message, message.delivery_tag)
  File "c:\anaconda3\envs\lion\lib\site-packages\kombu\transport\redis.py", line 146, in append
    pipe.zadd(self.unacked_index_key, delivery_tag, time()) \
  File "c:\anaconda3\envs\lion\lib\site-packages\redis\client.py", line 2320, in zadd
    for pair in iteritems(mapping):
  File "c:\anaconda3\envs\lion\lib\site-packages\redis\_compat.py", line 109, in iteritems
    return iter(x.items())
AttributeError: 'str' object has no attribute 'items'
 

我使用的版本是 

Django==1.11.6
django-celery==3.2.2
celery==3.1.26.post2

报错原因我的是:django-redis 版本不匹配

使用

django-redis==4.7.0

redis==2.10.6

还有一个原因可能是您没有迁移数据库,迁移后就没问题了

猜你喜欢

转载自blog.csdn.net/weixin_37989267/article/details/88812698