-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
None
When the CursorNotFound bit is set on a getMore result PyMongo raises OperationFailure with an appropriate explanation. However, cursor.Cursor doesn't catch the exception and set its internal __killed flag to True. This means that 1) we pointlessly send OP_KILL_CURSORS to the server when the Cursor instance is destroyed and 2) Cursor.alive returns True when it should be returning False. A proposed fix:
- Raise a new exception for CursorNotFound, inheriting from OperationFailure so we don't break existing code.
- Catch the exception in cursor.Cursor and command_cursor.CommandCursor, setting __killed to True.
- If the cursor is not tailable re-raise the exception. This makes it easier to deal with capped collection roll over when iterating a tailable cursor.
http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#op-reply
Issue raised on mongodb-user: https://groups.google.com/forum/#!topic/mongodb-user/fX5MvfYjAXc