mutapath.MutaPath.lock

MutaPath.lock[source]

Generate a cached file locker for this file with the additional suffix ‘.lock’. If this path refers not to an existing file or to an existing folder, a dummy lock is returned that does not do anything.

Once this path is modified (cloning != modifying), the lock is released and regenerated for the new path.

Example

>>> my_path = Path('/home/doe/folder/sub')
>>> with my_path.lock:
...     my_path.write_text("I can write")