MongoDB(Motor) cursor id is not valid at server 问题

MongoDB(Motor) cursor id is not valid at server 问题

Python使用Motor驱动操作MongoDB导出数据时遇到cursor id is not valid at server的问题,主要是因为Cursor空闲时间超过10分钟被服务器回收。可以通过以下两个参数来解决这个问题:

  • no_cursor_timeout :设置cursor没有超时时间。
  • batch_size:设置每次获取的documet的个数。获取个数越少,处理时间越短,相当于缩短了cursor的空闲时间。

参考文档:Motor文档中的描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章