I started using pymongo's (version 2.2.1) ReplicaSetConnection object instead of the pymongo.Connection object. Now, when I perform reads from the database, like:
if cur.count() == 0:
raise NoDocumentsFound(self.name, self.COLLECTION_NAME)
elif cur.count() > 1:
raise TooManyDocumentsFound(self.name, self.COLLECTION_NAME)
cur.rewind()
rec = cur[0]
I sometimes receive an "IndexError: no such item for Cursor instance" on the final line. From all I can find out about this error, it should occur only when you don't have any records that match your query. However, I've clearly already checked that my cursor has items in it. Is there something odd going on with the ReplicaSetConnection which makes these read operations more volatile?