由於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, 不清楚原因,有知道的朋友也請不吝賜教。

[pymongo] pymongo.errors.CursorNotFound Exception的更多相关文章

  1. mongodb pymongo.errors.CursorNotFound: Cursor not found, cursor id: 82792803897

    默认 mongo server维护连接的时间窗口是十分钟 默认 单次从 server获取数据是101条或者 大于1M小于16M的数据 所以默认情况下,如果10分钟内未能处理完数据,则抛出该异常. 解决 ...

  2. 【pymongo.errors】Cursor not found

    pymongo.errors.CursorNotFound: Cursor not found 故事背景:先从数据库中取得所有数据 db['test'].find(),然后对结果进行for循环,但是当 ...

  3. [mongoDB]PyMongo Cursor Not Found Error

    Python跑一个aggregate脚本,报错:pymongo.errors.CursorNotFound: Cursor not found, cursor id: 35411720832 搜了下原 ...

  4. 高可用性和PyMongo

        High Availability and PyMongo高可用性和PyMongo************************************ PyMongo makes it e ...

  5. pymongo使用总结

    0. 何为pymongo pymongo是操作MongoDB的python模块 1.安装pymongo # easy_install pymongo 2.连接mongodb >>> ...

  6. pymongo连接MongoDB

    导语 pymongo 是目前用的相对普遍一个python用来连接MongoDB的库,是工作中各种基本需求都能满足具体api可以参考 pymongo APIpymongo github 安装 Mongo ...

  7. 7.mongo python 库 pymongo的安装

    1.Python 中如果想要和 MongoDB 进行交互就需要借助于 PyMongo 库,在CMD中使用命令即可[注意此处是pip3,pip无法安装]: pip3 install pymongo 2. ...

  8. JAVA fundamentals of exception handling mechanism

    Agenda Three Categories Of Exceptions Exceptions Hierarchy try-catch-finally block The try-with-reso ...

  9. [AngularJS] Catching errors with $exceptionHandler

    The AngularJS $exceptionHandler service allows you to catch and handle unanticipated JavaScript erro ...

随机推荐

  1. 使用python处理selenium中的获取元素属性

    # 获取我的订单元素class属性值 get_class_name = driver.find_element_by_link_text('我的订单').get_attribute('class') ...

  2. Linux 下 svn 多个项目多用户分配

    安装步骤如下: 1.yum install subversion 2.输入rpm -ql subversion查看安装位置,如下图: 输入 svn –help可以查看svn的使用方法 需求 开发服务器 ...

  3. 利用python jieba库统计政府工作报告词频

    1.安装jieba库 舍友帮装的,我也不会( ╯□╰ ) 2.上网寻找政府工作报告 3.参照课本三国演义词频统计代码编写 import jieba txt = open("D:\政府工作报告 ...

  4. Linux下用ls和du命令查看文件以及文件夹大小(转)

    转自:https://www.cnblogs.com/xueqiuqiu/p/7635722.html ls的用法 ls -l |grep "^-"|wc -l或find ./co ...

  5. ThreadLocal如何回收value,什么时候回收?(学习笔记)

    1)ThreadLocal如何回收value,什么时候回收?从ThreadLocal中的内部类分析:① static class ThreadLocalMap { /** * The entries ...

  6. UI系统综述:iOS的图形绘制、动画与runloop

    一.一条业务pipeline: 一个连接核心:coreanimation 二.两个进程: 1.app进程: 2.render进程: 首先,由 app 处理事件(Handle Events),如:用户的 ...

  7. int pthread_cond_wait(pthread_cond_t *restrict cond, pthread_mutex_t *restric mutex)

    mutex:为了保护条件变量而存在的: cond:为了线程通信而存在的. 整个机制都是为了保护条件变量和线程间通信而存在的. pthread_cond_wait()函数一进入wait状态就会自动rel ...

  8. oracle封装OracleHelper

    1.Oracle 封装类 using System; using System.Collections.Generic; using System.Linq; using System.Text; u ...

  9. 树上背包DP Luogu P2014 选课

    #include <cstdio> #include <cctype> #include <cstring> #include <algorithm> ...

  10. Shared Virtual Memory (SVM) Functions

    Description Shared Virtual Memory (SVM) (Glossary): An address space exposed to both the host and th ...