duck.utils.filelockΒΆ

File lock capabilities module.

Module ContentsΒΆ

FunctionsΒΆ

lock_file

Lock file when modifying or accessing critical sections to avoid race conditions.

open_and_lock

Opens a file and acquires an exclusive lock.

unlock_file

Unlock a locked file.

APIΒΆ

duck.utils.filelock.lock_file(file_descriptor, retries=5, wait=1)[source]ΒΆ

Lock file when modifying or accessing critical sections to avoid race conditions.

duck.utils.filelock.open_and_lock(filename, mode='r+')[source]ΒΆ

Opens a file and acquires an exclusive lock.

Parameters:
  • filename – The name of the file to open.

  • mode – The file open mode (default is β€˜r+’).

Returns:

The opened file object.

duck.utils.filelock.unlock_file(file_descriptor)[source]ΒΆ

Unlock a locked file.