【发布时间】:2016-01-03 11:15:36
【问题描述】:
您好,我正在使用 mongo_collection.find() 从 mongdb 获取文档,此集合有 600k 文档。遍历 400k 文档后,我遇到了错误
Traceback (most recent call last):
File "mongo_opp.py", line 324, in <module>
obj.indexAnswer()
File "mongo_opp.py", line 241, in indexAnswer
for dict_result in result:
File "build/bdist.linux-x86_64/egg/pymongo/cursor.py", line 1032, in next
File "build/bdist.linux-x86_64/egg/pymongo/cursor.py", line 974, in _refresh
File "build/bdist.linux-x86_64/egg/pymongo/cursor.py", line 864, in __send_message
File "build/bdist.linux-x86_64/egg/pymongo/helpers.py", line 112, in _unpack_response
pymongo.errors.CursorNotFound: Cursor not found, cursor id: 83302133311
这个问题的解决方案是设置超时参数mongo_collection.find(timeout=False),我在下面的链接中找到了,
设置超时参数会使游标无限时间打开,会影响系统性能。任何人都可以帮助我解决光标关闭连接。帮助表示赞赏:)
【问题讨论】:
标签: mongodb python-2.7