由於find之後,loop執行時間過長導致timeout, cusor失效
解決方式有以下幾種:
1. 使用batch_size()
cursor = collection.find({}).batch_size(30)
2. 將取出的cursor轉為list
result = list(collection.find({}))
3. 取消timeout限制,要在cursor使用之後close
cursor = collection.find({}, no_cursor_timeout=True)
cursor.close()
[pymongo] pymongo.errors.CursorNotFound Exception
原文:https://www.cnblogs.com/sipher/p/11406898.html