由於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() 

# 最後一種方式,在使用時依然出現exception, 不清楚原因,有知道的朋友也請不吝賜教。

相关文章:

  • 2022-12-23
  • 2021-05-31
  • 2021-08-19
  • 2021-05-26
  • 2022-12-23
  • 2021-08-17
  • 2021-12-09
  • 2021-07-12
猜你喜欢
  • 2021-12-21
  • 2021-07-28
  • 2021-07-26
  • 2022-12-23
  • 2021-10-14
相关资源
相似解决方案