zoukankan      html  css  js  c++  java
  • Celery ValueError: not enough values to unpack (expected 3, got 0)的解决方案

    本地环境如下:

    Windows 10
    Python 3.5.2
    Celery 4.1.0

      代码tasks.py:

    from celery import Celery
    
    app
    = Celery('tasks', broker='redis://:xxxx@xxx.xxx.xxx.xx:6379/0') @app.task def add(x, y): return x + y

      执行worker  celery -A tasks worker --loglevel=info

    -------------- celery@kong9wei11 v4.1.0 (latentcall)
    ---- **** -----
    --- * *** * -- Windows-10-10.0.14393-SP0 2018-01-12 19:01:39
    -- * - **** ---
    - ** ---------- [config]
    - ** ---------- .> app: tasks:0x157fd248550
    - ** ---------- .> transport: redis://:**@114.67.225.0:6379/0
    - ** ---------- .> results: disabled://
    - *** --- * --- .> concurrency: 4 (prefork)
    -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
    --- ***** -----
    -------------- [queues]
    .> celery exchange=celery(direct) key=celery
    
    
    [tasks]
    . tasks.add
    
    [2018-01-12 19:01:40,029: INFO/MainProcess] Connected to redis://:**@114.67.225.0:6379/0
    [2018-01-12 19:01:40,130: INFO/MainProcess] mingle: searching for neighbors
    [2018-01-12 19:01:40,550: INFO/SpawnPoolWorker-1] child process 9048 calling self.run()
    [2018-01-12 19:01:40,557: INFO/SpawnPoolWorker-2] child process 9028 calling self.run()
    [2018-01-12 19:01:40,578: INFO/SpawnPoolWorker-3] child process 13064 calling self.run()
    [2018-01-12 19:01:40,611: INFO/SpawnPoolWorker-4] child process 9856 calling self.run()
    [2018-01-12 19:01:41,693: INFO/MainProcess] mingle: all alone
    [2018-01-12 19:01:42,212: INFO/MainProcess] celery@xx ready.

    调用任务代码manager.py:

    from tasks import add
    add.delay(4, 4)

      启动项目时,

    python manager.py

      worker以下报错:

    [2018-01-12 19:08:15,545: INFO/MainProcess] Received task: tasks.add[5d387722-5389-441b-9b01-a619b93b4702]
    [2018-01-12 19:08:15,550: ERROR/MainProcess] Task handler raised error: ValueError('not enough values to unpack (expected 3, got 0)',)
    Traceback (most recent call last):
    File
    "d:programmingsoftwarepython35libsite-packagesilliardpool.py", line 358, in workloop result = (True, prepare_result(fun(*args, **kwargs)))
    File
    "d:programmingsoftwarepython35libsite-packagesceleryapp race.py", line 525, in _fast_trace_task tasks, accept, hostname = _loc
    ValueError: not enough values to unpack (expected
    3, got 0)

    看别人描述大概就是说win10上运行celery4.x就会出现这个问题,解决办法如下,原理未知:

      

      先安装一个`eventlet

    pip install eventlet

      然后启动worker的时候加一个参数,如下:然后就可以正常的调用了。

    celery -A <mymodule> worker -l info -P eventlet

      启动django项目

    python manage.py

      worker里输出:

    [2018-01-12 19:35:33,640: INFO/MainProcess] Received task: tasks.add[3f9b5255-60a2-4a08-96b6-38f5fbc31543]
    [2018-01-12 19:35:33,640: INFO/MainProcess] Task tasks.add[3f9b5255-60a2-4a08-96b6-38f5fbc31543] succeeded



  • 相关阅读:
    web----VLAN
    安装 Android Studio 2.3.2
    对于“2017面向对象程序设计(Java)第三周学习总结”存在问题的反馈
    2017面向对象程序设计(JAVA)第3周学习指导及要求(2017.9.6-2017.9.12)
    第3周教学课件及实验任务已发布!
    关于字符串比较
    优秀博文推荐
    新手如何学习Java——Java学习路线图
    2017面向对象程序设计(Java)第2周学习指导及要求(2017.8.28-2017.9.3)
    第二周教学课件及实验任务已发布!
  • 原文地址:https://www.cnblogs.com/AbnerLc/p/12081323.html
Copyright © 2011-2022 走看看