celery接收到任务后出现错误,ValueError: not enough values to unpack (expected 3, got 0)

Posted sewen-h

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了celery接收到任务后出现错误,ValueError: not enough values to unpack (expected 3, got 0)相关的知识,希望对你有一定的参考价值。

(env) D:python_learnmeiduo_projectmeiduo_mall>celery -A celery_tasks.main worker -l info

 -------------- celery@CZZI-BBMGSW v4.4.6 (cliffs)
--- ***** -----
-- ******* ---- Windows-7-6.1.7601-SP1 2020-07-18 23:06:20
- *** --- * ---
- ** ---------- [config]
- ** ---------- .> app:         meiduo:0x3676250
- ** ---------- .> transport:   amqp://admin:**@192.168.2.155:5672//
- ** ---------- .> results:     disabled://
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
 -------------- [queues]
                .> celery           exchange=celery(direct) key=celery


[tasks]
  . ccp_send_sms_code

[2020-07-18 23:06:21,241: INFO/MainProcess] Connected to amqp://admin:**@192.168.2.155:5672//
[2020-07-18 23:06:21,257: INFO/MainProcess] mingle: searching for neighbors
[2020-07-18 23:06:21,422: INFO/SpawnPoolWorker-1] child process 14532 calling self.run()
[2020-07-18 23:06:21,422: INFO/SpawnPoolWorker-2] child process 16500 calling self.run()
[2020-07-18 23:06:21,462: INFO/SpawnPoolWorker-3] child process 9492 calling self.run()
[2020-07-18 23:06:21,613: INFO/SpawnPoolWorker-4] child process 7784 calling self.run()
[2020-07-18 23:06:22,318: INFO/MainProcess] mingle: all alone
[2020-07-18 23:06:22,374: INFO/MainProcess] celery@CZZI-BBMGSW ready.
[2020-07-18 23:08:42,415: INFO/MainProcess] Received task: ccp_send_sms_code[9dc4d018-b1fb-45e0-b395-89ba2b952146]
[2020-07-18 23:08:42,448: ERROR/MainProcess] Task handler raised error: ValueError(not enough values to unpack (expected 3, got 0))
Traceback (most recent call last):
  File "d:python_learnmeiduo_projectenvlibsite-packagesilliardpool.py", line 362, in workloop
    result = (True, prepare_result(fun(*args, **kwargs)))
  File "d:python_learnmeiduo_projectenvlibsite-packagesceleryapp	race.py", line 600, in _fast_trace_task
    tasks, accept, hostname = _loc
ValueError: not enough values to unpack (expected 3, got 0)

 

 运行celery4.x版本就会出现这个问题,解决办法是安装一个eventlet

pip install eventlet

再次启动celery执行任务:

celery -A celery_tasks.tasks worker -l info -P eventlet 

问题解决

技术图片

 

以上是关于celery接收到任务后出现错误,ValueError: not enough values to unpack (expected 3, got 0)的主要内容,如果未能解决你的问题,请参考以下文章

Django使用Celery异步任务队列

Celery 基本使用

错误:无法加载 celery 应用程序。未找到模块任务

Django 学习之Celery(芹菜)

Django Celery 接收和接受任务,但不执行它们

Flask 学习-59.解决celery 在windows 上接收任务不执行的问题