pyufunc.safe_write_text_with_lock#

pyufunc.safe_write_text_with_lock(path, text, *, lock_path=None, encoding='utf-8', timeout=-1)#

Write text while holding a file lock.

Parameters:
  • path – Destination file path.

  • text – Text content to write.

  • lock_path – Optional lock-file path. Defaults to path plus .lock.

  • encoding – Text encoding used for writing.

  • timeout – Maximum seconds to wait for the lock.

Note

Example

>>> safe_write_text_with_lock("note.txt", "hello")
Returns:

The destination path.

Return type:

Path