window下celery正常启动后能收到任务但不执行任务的解决办法

window下celery正常启动后能收到任务但不执行任务的解决办法

解决办法,启动的时候,使用eventlet 方式,

pip install eventlet 

celery -A celery_tasks worker -l info -P eventlet  -c 10

##-c是协程的数量,生产环境可以用1000

原因:celery不支持在windows下运行任务,需要借助eventlet来完成……

执行以上命令,如遇到以下报错:

报错内容:DatabaseWrapper objects created in a thread can only be used in that same thread.

DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 2762156319136 and this is thread id 2762243715664.

 解决方案:

celery -A celery_tasks worker -l info -P solo -c 10