def _refresh(self):
        """Refreshes the cursor with more data from Mongo.

        Returns the length of self.__data after refresh. Will exit early if
        self.__data is already non-empty. Raises OperationFailure when the
        cursor cannot be refreshed due to an error on the query.
        """
        if len(self.__data) or self.__killed:
            return len(self.__data)

        if self.__id is None:  # Query
            self.__send_message(_Query(self.__query_flags,
                                       self.__collection.database.name,
                                       self.__collection.name,
                                       self.__skip,
                                       self.__query_spec(),
                                       self.__projection,
                                       self.__codec_options,
                                       self.__read_preference,
                                       self.__limit,
                                       self.__batch_size,
                                       self.__read_concern,
                                       self.__collation))
            if not self.__id:
                self.__killed = True
        elif self.__id:  # Get More
            if self.__limit:
                limit = self.__limit - self.__retrieved
                if self.__batch_size:
                    limit = min(limit, self.__batch_size)
            else:
                limit = self.__batch_size

            # Exhaust cursors don't send getMore messages.
            if self.__exhaust:
                self.__send_message(None)
            else:
                self.__send_message(_GetMore(self.__collection.database.name,
                                             self.__collection.name,
                                             limit,
                                             self.__id,
                                             self.__codec_options,
                                             self.__max_await_time_ms))

        else:  # Cursor id is zero nothing else to return
            self.__killed = True

        return len(self.__data)
def _refresh ( self ) : if len ( self . __data ) or self . __killed : return len ( self . __data ) if self . __id is None : self . __send_message ( _Query ( self . __query_flags , self . __collection . database . name , self . __collection . name , self . __skip , self . __query_spec ( ) , self . __projection , self . __codec_options , self . __read_preference , self . __limit , self . __batch_size , self . __read_concern , self . __collation ) ) if not self . __id : self . __killed = True elif self . __id : if self . __limit : limit = self . __limit - self . __retrieved if self . __batch_size : limit = min ( limit , self . __batch_size ) else : limit = self . __batch_size if self . __exhaust : self . __send_message ( None ) else : self . __send_message ( _GetMore ( self . __collection . database . name , self . __collection . name , limit , self . __id , self . __codec_options , self . __max_await_time_ms ) ) else : self . __killed = True return len ( self . __data )
Refreshes the cursor with more data from Mongo.

        Returns the length of self.__data after refresh. Will exit early if
        self.__data is already non-empty. Raises OperationFailure when the
        cursor cannot be refreshed due to an error on the query.