场景
Flask开发中用celery 6正常启动后能收到任务但不执行任务的解决办法,也没有错误提示……
INFO/MainProcess] Task app.add_together[ce406ed8-71b3-49e6-8556-f44bfe66549c] received
[2024-06-20 19:38:10,632: INFO/SpawnPoolWorker-36] child process 22448 calling self.run()
[2024-06-20 19:38:11,092: INFO/SpawnPoolWorker-35] child process 23688 calling self.run()
[2024-06-20 19:38:11,208: INFO/SpawnPoolWorker-37] child process 23756 calling self.run()
[2024-06-20 19:38:11,221: INFO/SpawnPoolWorker-34] child process 3888 calling self.run()
[2024-06-20 19:38:11,216: INFO/SpawnPoolWorker-38] child process 24568 calling self.run()
[2024-06-20 19:38:11,330: INFO/SpawnPoolWorker-41] child process 22980 calling self.run()
[2024-06-20 19:38:11,660: INFO/SpawnPoolWorker-39] child process 21820 calling self.run()
[2024-06-20 19:38:12,074: INFO/SpawnPoolWorker-40] child process 6784 calling self.run()
操作系统:WINDOWS10
PYTHON环境:311
IDEA:Pycharm 2023.3.3
QUEUE: REDIS最新版
解决
经过小半天的不停地尝试各种办法,终于找到了解决方案,那就是:celery不支持在windows下运行任务,需要借助eventlet来完成
运行
pip install eventlet
celery -A celery_tasks.main worker -l info -P eventlet -c 100
正常了,但是这个celery相对来说还是挺坑爹的,后面计划把这个改成JAVA队列服务。
总结
celery鉴定为坑