django - Django Celery递归错误与tasks.py,不与views.py
问题描述
我创建了一个递归函数来获取某个对象的所有子对象。
def get_all_children(self):
children = [self]
try:
child_list = self.children.all()
except AttributeError:
return children
for child in child_list:
children.extend(child.get_all_children())
return children
当我在 views.py 文件中调用此函数时,它工作正常。但它给了我一个 RecursionError: maximum recursion depth exceeded in contrast when I call the same function in my celery tasks.py 文件
解决方案
推荐阅读
- python - Python:超出范围
- python-3.x - Keras Model hdf5 无法转换 Tflite
- python - Python 和 selenium:如何多次更改 Firefox 的配置文件
- python - 如何迭代查询集并附加到字符串
- reactjs - 为什么我的 React 组件进入无限循环?
- python - 使用字典查找列表列表的最大值和最小值
- django - 在heroku中部署django应用程序后TemplateDoesNotFound错误
- flutter - 当抖动中不存在图像时处理图像错误
- python - Python Web Scraping 没有得到所有的 HTML
- python - Simpleaudio wav 文件只播放一次