lock_and_write_buffer#

caput.util.mpitools.lock_and_write_buffer(obj: object, fname: str, offset: int, size: int) None[source]#

Write buffer contents to disk at a given locked offset.

Write the contents of a buffer to disk at a given offset, and explicitly lock the region of the file whilst doing so.

Parameters:
objobject

Data to write to disk. Must support the buffer protocol (i.e., be callable by memoryview()).

fnamestr

Filename to write.

offsetint

Offset into the file to start writing at.

sizeint

Size of the region to write to (and lock).