MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _next_batch

Method _next_batch

pymongo/asynchronous/cursor.py:1149–1165  ·  view source on GitHub ↗

Get all or some documents from the cursor.

(self, result: list, total: Optional[int] = None)

Source from the content-addressed store, hash-verified

1147 raise StopAsyncIteration
1148
1149 async def _next_batch(self, result: list, total: Optional[int] = None) -> bool: # type: ignore[type-arg]
1150 """Get all or some documents from the cursor."""
1151 if not self._exhaust_checked:
1152 self._exhaust_checked = True
1153 await self._supports_exhaust()
1154 if self._empty:
1155 return False
1156 if len(self._data) or await self._refresh():
1157 if total is None:
1158 result.extend(self._data)
1159 self._data.clear()
1160 else:
1161 for _ in range(min(len(self._data), total)):
1162 result.append(self._data.popleft())
1163 return True
1164 else:
1165 return False
1166
1167 async def __anext__(self) -> _DocumentType:
1168 return await self.next()

Callers

nothing calls this directly

Calls 3

_supports_exhaustMethod · 0.95
_refreshMethod · 0.95
clearMethod · 0.45

Tested by

no test coverage detected