pymongo操作错误

时间:2013-02-20 15:43:17

标签: python mongodb pymongo

我从MongoDB获取了大量记录,并且我收到了错误

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

这是什么意思,我该如何解决它。我不知道这是否重要,但我做到了 我打开连接时使用from gevent import monkey; monkey.patch_all()

1 个答案:

答案 0 :(得分:1)

当光标长时间打开而没有操作时,它(光标)可以超时 - &gt;这会导致错误

您可以在查找查询中设置timeout = False以关闭超时

reference