pyufunc.safe_write_pickle_with_lock#

pyufunc.safe_write_pickle_with_lock(path, data, *, lock_path=None, timeout=-1, protocol=5)#

Write pickle data while holding a file lock.

Parameters:
  • path – Destination file path.

  • data – Object to pickle.

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

  • timeout – Maximum seconds to wait for the lock.

  • protocol – Pickle protocol version.

Note

Example

>>> safe_write_pickle_with_lock("data.pkl", {"ok": True})
Returns:

The destination path.

Return type:

Path