OpenQuizz
Une application de gestion des contenus pédagogiques
CommandCursor Class Reference
Inheritance diagram for CommandCursor:
Collaboration diagram for CommandCursor:

Public Member Functions

def __init__ (self, collection, cursor_info, address, retrieved=0, batch_size=0, max_await_time_ms=None, session=None, explicit_session=False)
 
def __del__ (self)
 
def close (self)
 
def batch_size (self, batch_size)
 
def alive (self)
 
def cursor_id (self)
 
def address (self)
 
def session (self)
 
def __iter__ (self)
 
def next (self)
 
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_val, exc_tb)
 

Detailed Description

A cursor / iterator over command cursors.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  collection,
  cursor_info,
  address,
  retrieved = 0,
  batch_size = 0,
  max_await_time_ms = None,
  session = None,
  explicit_session = False 
)
Create a new command cursor.

The parameter 'retrieved' is unused.

Reimplemented in RawBatchCommandCursor.

◆ __del__()

def __del__ (   self)

Member Function Documentation

◆ __enter__()

def __enter__ (   self)

◆ __exit__()

def __exit__ (   self,
  exc_type,
  exc_val,
  exc_tb 
)

◆ __iter__()

def __iter__ (   self)

◆ address()

def address (   self)
The (host, port) of the server used, or None.

.. versionadded:: 3.0

◆ alive()

def alive (   self)
Does this cursor have the potential to return more data?

Even if :attr:`alive` is ``True``, :meth:`next` can raise
:exc:`StopIteration`. Best to use a for loop::

    for doc in collection.aggregate(pipeline):
print(doc)

.. note:: :attr:`alive` can be True while iterating a cursor from
  a failed server. In this case :attr:`alive` will return False after
  :meth:`next` fails to retrieve the next batch of results from the
  server.

◆ batch_size()

def batch_size (   self,
  batch_size 
)
Limits the number of documents returned in one batch. Each batch
requires a round trip to the server. It can be adjusted to optimize
performance and limit data transfer.

.. note:: batch_size can not override MongoDB's internal limits on the
   amount of data it will return to the client in a single batch (i.e
   if you set batch size to 1,000,000,000, MongoDB will currently only
   return 4-16MB of results per batch).

Raises :exc:`TypeError` if `batch_size` is not an integer.
Raises :exc:`ValueError` if `batch_size` is less than ``0``.

:Parameters:
  - `batch_size`: The size of each batch of results requested.

◆ close()

def close (   self)
Explicitly close / kill this cursor.

◆ cursor_id()

def cursor_id (   self)
Returns the id of the cursor.

◆ next()

def next (   self)
Advance the cursor.

◆ session()

def session (   self)
The cursor's :class:`~pymongo.client_session.ClientSession`, or None.

.. versionadded:: 3.6

The documentation for this class was generated from the following file: