Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyMongo: What happens to cursor when no_cursor_timeout=True

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?

like image 903
sunny Avatar asked Jul 15 '15 19:07

sunny


1 Answers

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.

like image 67
Roi Tal Avatar answered Sep 26 '22 03:09

Roi Tal