PyMongo: What happens to cursor when no_cursor_timeout=True

元气小坏坏 提交于 2019-12-12 10:55:44

问题


Looking at the cursor docs for MongoDB, I don't see a way to delete a cursor. What happens in PyMongo if I am using a cursor with the no_cursor_timeout property set to True? Is the cursor deleted when my script terminates even if I have not gotten to the end of the cursor's results?


回答1:


Python uses reference counting for object lifetime management, when the Cursor object goes out of scope the garbage collector would call __die() which closes the cursor. If you want explicit control, you can call close() by yourself.



来源:https://stackoverflow.com/questions/31438909/pymongo-what-happens-to-cursor-when-no-cursor-timeout-true

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!