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.


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