mongo请求超时

no_cursor_timeout=True参数的使用
默认拿到cursor后,十分钟内不取数倨或者十分钟内每把数据取完,再继续取,会有timeout的的报错(所以针对取了数据做了很耗时的操作,在这边最好加上这个参数)
 

实例:

import pymongo
 
handler = pymongo.MongoClient().db.col
with handler.find(no_cursor_timeout=True) as cursor:
 for row in cursor:
  parse_data(row)
posted @ 2020-01-04 21:36  阿布_alone  阅读(675)  评论(0编辑  收藏  举报
TOP