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文檔中的描述