Celery提交任务出错?

Posted yunlongaimeng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Celery提交任务出错?相关的知识,希望对你有一定的参考价值。

跟着官方的入门教程部署和运行的,为啥报这个错?

tasks.py

# -*- encoding:UTF-8 -*-

from celery import Celery

brokers = redis://localhost:6379
backend = redis://localhost:6379

app = Celery(tasks, broker=brokers, backend=backend)
app.control.purge()


@app.task
def add(x, y):
    return x + y

 

技术分享图片

 

>>> from tasks import add
>>> add.delay(6,6)
<AsyncResult: e1b8521e-e8a1-4431-8232-b0cbe7a35e9e>
 
[2017-08-08 19:14:32,580: ERROR/MainProcess] Task handler raised error: ValueErr
or(not enough values to unpack (expected 3, got 0),)
Traceback (most recent call last):
  File "c:python352libsite-packagesilliardpool.py", line 358, in workloop
    result = (True, prepare_result(fun(*args, **kwargs)))
  File "c:python352libsite-packagesceleryapp	race.py", line 525, in _fast_
trace_task
    tasks, accept, hostname = _loc
ValueError: not enough values to unpack (expected 3, got 0)
[2017-08-08 19:15:46,049: ERROR/MainProcess] Task handler raised error: ValueErr
or(not enough values to unpack (expected 3, got 0),)
Traceback (most recent call last):
  File "c:python352libsite-packagesilliardpool.py", line 358, in workloop
    result = (True, prepare_result(fun(*args, **kwargs)))
  File "c:python352libsite-packagesceleryapp	race.py", line 525, in _fast_
trace_task
    tasks, accept, hostname = _loc
ValueError: not enough values to unpack (expected 3, got 0)

解决方案:celery -A your_app_name worker --pool=solo -l info 换这个试试

以上是关于Celery提交任务出错?的主要内容,如果未能解决你的问题,请参考以下文章

如何在 celery 任务中强制 django-orm 中的单个保存的 db 提交

如何从 django 模板暂停和停止 celery 任务

Celery 检查工作任务并检索任务文档字符串

创建 celery 任务然后同步运行

如何设置 Celery 在运行任务之前调用自定义初始化函数?

Python - Celery