lock_file#

class caput.memdata.lock_file(filename, preserve=False, comm=None)[source]#

Manage a lock file around a file creation operation.

Parameters:
filenamestr

Final name for the file.

preservebool, optional

Keep the temporary file in the event of failure.

commMPI.Comm | None, optional

If not None, only rank=0 will create/remove the lock file and move the file.

Examples

>>> from caput import memdata
>>> container = memdata.MemDiskGroup()
>>> with lock_file("file_to_create.h5") as fname:
...     container.save(fname)
property lockfile[source]#

Full path to the lockfile (with file extension).

property tmpfile[source]#

Full path to the lockfile (without file extension).