问题
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