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

Method _write_async

gridfs/asynchronous/grid_file.py:1399–1417  ·  view source on GitHub ↗
(self, read: Any)

Source from the content-addressed store, hash-verified

1397 self._buffer.write(to_write)
1398
1399 async def _write_async(self, read: Any) -> None:
1400 if self._buffer.tell() > 0:
1401 # Make sure to flush only when _buffer is complete
1402 space = self.chunk_size - self._buffer.tell()
1403 if space:
1404 try:
1405 to_write = await read(space)
1406 except BaseException:
1407 await self.abort()
1408 raise
1409 self._buffer.write(to_write)
1410 if len(to_write) < space:
1411 return # EOF or incomplete
1412 await self._flush_buffer()
1413 to_write = await read(self.chunk_size)
1414 while to_write and len(to_write) == self.chunk_size:
1415 await self._flush_data(to_write)
1416 to_write = await read(self.chunk_size)
1417 self._buffer.write(to_write)
1418
1419 async def writelines(self, sequence: Iterable[Any]) -> None:
1420 """Write a sequence of strings to the file.

Callers 1

writeMethod · 0.95

Calls 6

abortMethod · 0.95
_flush_bufferMethod · 0.95
_flush_dataMethod · 0.95
readFunction · 0.50
tellMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected