调试celery遇到的坑

用的例子是

https://www.jianshu.com/p/620052aadbff

调试过程中遇到的问题

1、worker运行后执行任务报错

ValueError: not enough values to unpack (expected 3, got 0)

https://www.cnblogs.com/sewen-H/p/13338198.html解决

。我测试环境是win7,好多帖子都是安装 eventlet解决而我还是报错,没办法又回退版本,结果又报错:

from kombu.async.timer import Entry, Timer as Schedule, to_timestamp, logger

^

SyntaxError: invalid syntax

,最后让我找到了上面的贴子安装了个gevent解决。

2、worker运行后执行任务报错

File “c:\users\administrator\pycharmprojects\untitled\venv\lib\site-packages\celery\worker\con

sumer\consumer.py”, line 562, in on_task_received

strategy = strategies[type_]

KeyError: ‘test_celery.celery_app_task.add’

找了好久都没有找到解决方案,最后看到一条报错

[2020-09-09 19:44:31,552: ERROR/MainProcess] Received unregistered task of type ‘test_celery.cel

ery_app_task.add’.

百度之https://blog.csdn.net/u014108439/article/details/83782531

发现原来是task没给name参数

更多推荐