Python 如何查找kill_cursors()的游标\u id?
PyMongo API文档提到了一个杀死mongodb游标的函数:Python 如何查找kill_cursors()的游标\u id?,python,mongodb,cursor,pymongo,Python,Mongodb,Cursor,Pymongo,PyMongo API文档提到了一个杀死mongodb游标的函数: kill_cursors(cursor_ids) Send a kill cursors message with the given ids. Raises TypeError if cursor_ids is not an instance of list. Parameters : cursor_ids: list of cursor ids to kill 但是,它没有指定(据我所知)如何实际查找光标的id。我
kill_cursors(cursor_ids) Send a kill cursors message with the given ids.
Raises TypeError if cursor_ids is not an instance of list.
Parameters : cursor_ids: list of cursor ids to kill
但是,它没有指定(据我所知)如何实际查找光标的id。我怎么能得到这个
from pymongo import Connection
c = Connection()
crawl = c.db.coll.find()
print crawl.id? <-- no idea how to get this
从pymongo导入连接
c=连接()
爬网=c.db.coll.find()
打印身份证 您永远不需要显式地终止游标。一旦从游标中检索到所有结果,服务器将自动清理游标。(例如,在collection.find()循环中使用for doc。)如果没有检索到所有结果,PyMongo将在取消引用其游标实例时自动终止游标。例如:
对于集合中的文档。查找():
断言为False#引发异常
当光标超出范围时,PyMongo会自动调用kill_cursors来清理光标服务器端。Jesse,如果我发现光标是恶意光标,或者在测试过程中,我可能仍然希望显式地杀死它。在java脚本管理控制台中具有该选项将是一个加号。除此之外,我们是否有办法列出mongo服务器上所有打开的游标 一旦游标被执行,它就在游标中。_cursor_id(在执行游标之前将设置为0)是。这是一个后续问题。我们有办法在mongo中打印所有打开的游标ID吗?所以请打开一个新问题。谢谢