pymongo operation error
Question: I am getting a lot of records from my MongoDB and along the way I get an error

    
    
    File "C:\database\models\mongodb.py", line 228, in __iter__
        for result in self.results:
      File "C:\Python27\Lib\site-packages\pymongo\cursor.py", line 814, in next
        if len(self.__data) or self._refresh():
      File "C:\Python27\Lib\site-packages\pymongo\cursor.py", line 776, in _refresh
        limit, self.__id))
      File "C:\Python27\Lib\site-packages\pymongo\cursor.py", line 720, in __send_message
        self.__uuid_subtype)
      File "C:\Python27\Lib\site-packages\pymongo\helpers.py", line 99, in _unpack_response
        cursor_id)
    
    pymongo.errors.OperationFailure: cursor id '866472135294727793' not valid at server
    Exception KeyError: KeyError(38556896,) in <module 'threading' from 'C:\Python27\lib\threading.pyc'> ignored
    

What does this mean and how do I fix it. I don't know if it matters but I did
use `from gevent import monkey; monkey.patch_all()` when I opened the
connection


Answer: When the cursor has been open for a long time with no operations on it, it(the
cursor) can timeout -> this leads to the error

you can set timeout=False in your find query to turn the timeout off

[reference](http://api.mongodb.org/python/current/faq.html#what-does-
operationfailure-cursor-id-not-valid-at-server-mean)

