celery 启动后等10几秒就报有关于ping command 的错误

celery版本是 4.4.7
django版本是 3.1
redis版本是 Redis server v=2.8.4

报错信息是:

[2021-06-22 10:59:45,795: CRITICAL/MainProcess] Unrecoverable error: ResponseError("wrong number of arguments for 'ping' command")
Traceback (most recent call last):
  File "/usr/local/python39/lib/python3.9/site-packages/celery/worker/worker.py", line 208, in start
    self.blueprint.start(self)
  File "/usr/local/python39/lib/python3.9/site-packages/celery/bootsteps.py", line 119, in start
    step.start(parent)
  File "/usr/local/python39/lib/python3.9/site-packages/celery/bootsteps.py", line 369, in start
    return self.obj.start()
  File "/usr/local/python39/lib/python3.9/site-packages/celery/worker/consumer/consumer.py", line 318, in start
    blueprint.start(self)
  File "/usr/local/python39/lib/python3.9/site-packages/celery/bootsteps.py", line 119, in start
    step.start(parent)
  File "/usr/local/python39/lib/python3.9/site-packages/celery/worker/consumer/consumer.py", line 599, in start
    c.loop(*c.loop_args())
  File "/usr/local/python39/lib/python3.9/site-packages/celery/worker/loops.py", line 83, in asynloop
    next(loop)
  File "/usr/local/python39/lib/python3.9/site-packages/kombu/asynchronous/hub.py", line 364, in create_loop
    cb(*cbargs)
  File "/usr/local/python39/lib/python3.9/site-packages/kombu/transport/redis.py", line 1083, in on_readable
    self.cycle.on_readable(fileno)
  File "/usr/local/python39/lib/python3.9/site-packages/kombu/transport/redis.py", line 354, in on_readable
    chan.handlers[type]()
  File "/usr/local/python39/lib/python3.9/site-packages/kombu/transport/redis.py", line 688, in _receive
    ret.append(self._receive_one(c))
  File "/usr/local/python39/lib/python3.9/site-packages/kombu/transport/redis.py", line 698, in _receive_one
    response = c.parse_response()
  File "/usr/local/python39/lib/python3.9/site-packages/redis/client.py", line 3506, in parse_response
    response = self._execute(conn, conn.read_response)
  File "/usr/local/python39/lib/python3.9/site-packages/redis/client.py", line 3480, in _execute
    return command(*args, **kwargs)
  File "/usr/local/python39/lib/python3.9/site-packages/redis/connection.py", line 757, in read_response
    raise response
redis.exceptions.ResponseError: wrong number of arguments for 'ping' command

查看celery的github源码站提示,发现要求的redis版本是redis>=3.2.0

所以更新下redis版本即可。到redis官网下载下源码包:

wget http://download.redis.io/releases/redis-5.0.4.tar.gz
cd /tmp/
tar xf redis-5.0.4.tar.gz
cd redis-5.0.4/
make
make test

启动redis后,重新启动celery就可以了。不会报错。

posted @ 2021-06-22 18:30  温柔易淡  阅读(420)  评论(1编辑  收藏  举报