pymongo.errors.CursorNotFound: Cursor not found, cursor id: 124891571478

来源:互联网 发布:软件著作权 设计说明书 编辑:程序博客网 时间:2024/05/18 00:28

默认 mongo server维护连接的时间窗口是十分钟

默认 单次从 server获取数据是101条或者 大于1M小于16M的数据

所以默认情况下,如果10分钟内未能处理完数据,则抛出该异常。


解决办法:

1. 修改每批次获取数据量的条数,即batch size:

collection.find(condition).batch_size(5)

批量数需 估算十分钟内能处理的数据量


2. 延长超时时间 需显示的关闭cursor

cursor=db.images.find({}{'id':1,'image_path':1,'_id':0},no_cursor_timeout=True)
for i in cursor:   .....   .....cursor.close()

原创粉丝点击