Hi I am fetching documents from mongdb using mongo_collection.find() , this collection has 600k documents. after traversing 400k documents I am geting below error
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
The solutions to this problem is setting timeout paramter mongo_collection.find(timeout=False) which I found in below links,
StackOveflowLink1
StacKOverflowLink2
Setting timeout parameter makes cursor open for unlimited time, which will affect system performance. Can anybody help me with cursor close connection. Help appreciated :)
Hey you can solve this using del keyword
result = mongo_collection.find(no_cursor_timeout=True)
del result
Check Link1, Link2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With