执行异步任务时报错:django.db.utils.DatabaseError: DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias ‘default’ was created in thread id 3047101641304 and this is thread id 3047208084584.
原先启动命令(Windows下):
celery -A xxx worker -l info -P eventlet (xxx为项目名)
修改后的启动命令,celery版本4x:
celery -A xxx worker -l info -P solo
在Windows环境下,执行Celery异步任务时遇到了`django.db.utils.DatabaseError`,错误信息指出DatabaseWrapper对象在创建的线程中只能在同一线程内使用。原启动命令使用了`eventlet`,后改为使用`solo`参数启动Celery worker,以避免线程相关的问题。调整后的启动命令为:`celery -A xxx worker -l info -P solo`。
1232

被折叠的 条评论
为什么被折叠?



