Refreshes the cursor with more data from the server. 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.
(self)
| 204 | self._data = deque(documents) |
| 205 | |
| 206 | def _refresh(self) -> int: |
| 207 | """Refreshes the cursor with more data from the server. |
| 208 | |
| 209 | Returns the length of self._data after refresh. Will exit early if |
| 210 | self._data is already non-empty. Raises OperationFailure when the |
| 211 | cursor cannot be refreshed due to an error on the query. |
| 212 | """ |
| 213 | if len(self._data) or self._killed: |
| 214 | return len(self._data) |
| 215 | |
| 216 | if self._id: # Get More |
| 217 | dbname, collname = self._ns.split(".", 1) |
| 218 | read_pref = self._collection._read_preference_for(self.session) |
| 219 | self._send_message( |
| 220 | self._getmore_class( |
| 221 | dbname, |
| 222 | collname, |
| 223 | self._batch_size, |
| 224 | self._id, |
| 225 | self._collection.codec_options, |
| 226 | read_pref, |
| 227 | self._session, |
| 228 | self._collection.database.client, |
| 229 | self._max_await_time_ms, |
| 230 | self._sock_mgr, |
| 231 | False, |
| 232 | self._comment, |
| 233 | ) |
| 234 | ) |
| 235 | else: # Cursor id is zero nothing else to return |
| 236 | self._die_lock() |
| 237 | |
| 238 | return len(self._data) |
| 239 | |
| 240 | def __iter__(self) -> Iterator[_DocumentType]: |
| 241 | return self |
no test coverage detected