MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / _write_async

Method _write_async

gridfs/synchronous/grid_file.py:1387–1405  ·  view source on GitHub ↗
(self, read: Any)

Source from the content-addressed store, hash-verified

1385 self._buffer.write(to_write)
1386
1387 def _write_async(self, read: Any) -> None:
1388 if self._buffer.tell() > 0:
1389 # Make sure to flush only when _buffer is complete
1390 space = self.chunk_size - self._buffer.tell()
1391 if space:
1392 try:
1393 to_write = read(space)
1394 except BaseException:
1395 self.abort()
1396 raise
1397 self._buffer.write(to_write)
1398 if len(to_write) < space:
1399 return # EOF or incomplete
1400 self._flush_buffer()
1401 to_write = read(self.chunk_size)
1402 while to_write and len(to_write) == self.chunk_size:
1403 self._flush_data(to_write)
1404 to_write = read(self.chunk_size)
1405 self._buffer.write(to_write)
1406
1407 def writelines(self, sequence: Iterable[Any]) -> None:
1408 """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