Celery ValueError: not enough values to unpack (expected 3, got 0) 的解决方法(windows)

2023-02-18 14:02:58 浏览数 (1)

错误环境

  • windows        10
  • python           3.6
  • django           1.11
  • celery            4.3.0
  • django-celery-beat     1.5.0
  • django-celery-results  1.1.2

启动 celery 的命令

出错时启动命令:celery -A joyoo worker -l info

错误日志

代码语言:javascript复制
(joyoo) E:yinzhuoqundjangosjoyoo>celery -A joyoo worker -l info
raven.contrib.django.client.DjangoClient: 2020-02-27 16:50:46,534 e:py_virtualenvjoyoolibsite-packagesravenbase.py [line:213] INFO Raven is not configured (logging is disabled). Please see the documentation for more information.

 -------------- celery@DESKTOP-9K42C1Q v4.3.0 (rhubarb)
---- **** -----
--- * ***  * -- Windows-10-10.0.17763-SP0 2020-02-27 16:50:48
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app:         joyoo:0x1fe37781518
- ** ---------- .> transport:   redis://127.0.0.1:6379/0
- ** ---------- .> results:
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
 -------------- [queues]
                .> celery           exchange=celery(direct) key=celery


[tasks]
  . blog.tasks.task_check_friend_url
  . blog.tasks.task_request_save_visit_ip
  . blog.tasks.task_save_view_page
  . blog.tasks.task_send_dd_text
  . blog.tasks.task_send_mail
  . blog.tasks.task_web_save_visit_ip

[2020-02-27 16:50:48,445: INFO/MainProcess] Connected to redis://127.0.0.1:6379/0
[2020-02-27 16:50:48,454: INFO/MainProcess] mingle: searching for neighbors
[2020-02-27 16:50:49,281: INFO/SpawnPoolWorker-1] child process 25032 calling self.run()
[2020-02-27 16:50:49,309: INFO/SpawnPoolWorker-3] child process 23116 calling self.run()
[2020-02-27 16:50:49,347: INFO/SpawnPoolWorker-4] child process 33464 calling self.run()
[2020-02-27 16:50:49,353: INFO/SpawnPoolWorker-2] child process 20572 calling self.run()
[2020-02-27 16:50:49,475: INFO/MainProcess] mingle: all alone
[2020-02-27 16:50:49,506: WARNING/MainProcess] e:py_virtualenvjoyoolibsite-packagesceleryfixupsdjango.py:202: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
  warnings.warn('Using settings.DEBUG leads to a memory leak, never '
[2020-02-27 16:50:49,509: INFO/MainProcess] celery@DESKTOP-9K42C1Q ready.
raven.contrib.django.client.DjangoClient: 2020-02-27 16:50:54,303 e:py_virtualenvjoyoolibsite-packagesravenbase.py [line:213] INFO Raven is not configured (logging is disabled). Please see the documentation for more information.
raven.contrib.django.client.DjangoClient: 2020-02-27 16:50:54,318 e:py_virtualenvjoyoolibsite-packagesravenbase.py [line:213] INFO Raven is not configured (logging is disabled). Please see the documentation for more information.
raven.contrib.django.client.DjangoClient: 2020-02-27 16:50:54,337 e:py_virtualenvjoyoolibsite-packagesravenbase.py [line:213] INFO Raven is not configured (logging is disabled). Please see the documentation for more information.
raven.contrib.django.client.DjangoClient: 2020-02-27 16:50:54,375 e:py_virtualenvjoyoolibsite-packagesravenbase.py [line:213] INFO Raven is not configured (logging is disabled). Please see the documentation for more information.
[2020-02-27 16:50:59,028: INFO/MainProcess] Received task: blog.tasks.task_request_save_visit_ip[4802b66a-d2bd-4cea-83e4-aeb8898a30ff]
[2020-02-27 16:50:59,746: ERROR/MainProcess] Task handler raised error: ValueError('not enough values to unpack (expected 3, got 0)',)
Traceback (most recent call last):
  File "e:py_virtualenvjoyoolibsite-packagesbilliardpool.py", line 362, in workloop
    result = (True, prepare_result(fun(*args, **kwargs)))
  File "e:py_virtualenvjoyoolibsite-packagesceleryapptrace.py", line 544, in _fast_trace_task
    tasks, accept, hostname = _loc
ValueError: not enough values to unpack (expected 3, got 0)

解决方法

网上检索到资料 https://github.com/celery/celery/issues/4081

1. 安装 eventlet:

代码语言:javascript复制
(joyoo) E:yinzhuoqundjangosjoyoo>pip install eventlet
Requirement already satisfied: eventlet in e:py_virtualenvjoyoolibsite-packages (0.25.1)
Requirement already satisfied: greenlet>=0.3 in e:py_virtualenvjoyoolibsite-packages (from eventlet) (0.4.15)
Requirement already satisfied: dnspython>=1.15.0 in e:py_virtualenvjoyoolibsite-packages (from eventlet) (1.16.0)
Requirement already satisfied: six>=1.10.0 in e:py_virtualenvjoyoolibsite-packages (from eventlet) (1.11.0)
Requirement already satisfied: monotonic>=1.4 in e:py_virtualenvjoyoolibsite-packages (from eventlet) (1.5)
WARNING: You are using pip version 19.3.1; however, version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

2. 启动 celery 的启动命令换成:

代码语言:javascript复制
# moduleName 模块名,django 项目的话就是项目名
celery -A <moduleName> worker -l info -P eventlet

0 人点赞