Even with this change, "next" can raise StopIteration even though
"alive" is True. For example if batch size is 2 and there are 4
documents in the result set, then after the 4th document "alive" is True
but "next" raises StopIteration.
This change does a few things:
- Raises a new exception for CursorNotFound, inheriting from
OperationFailure so we don't break existing code.
- Catches the exception in cursor.Cursor and command_cursor.CommandCursor,
setting __killed to True.
- If the cursor is not tailable, re-raises the exception. This makes it
easier to deal with capped collection rollover when iterating a
tailable cursor.
This commit adds a helper for the new parallelCollectionScan
command introduced in MongoDB 2.5.5. The helper returns
"num_cursors" instances of CommandCursor that can be iterated
by one or more threads concurrently to scan the entire collection.
This commit also removes the remaining command cursor
hacks from cursor.Cursor.
The cursor returned by aggregate now knows what server
it was created on, allowing it to return getMore results
when the read preference is not PRIMARY.
This also introduces a simplified cursor class for use
with commands that return a cursor id and perhaps an initial
set of results. None of the methods of cursor.Cursor (other
than batch_size) make sense in this case.