optuna.storages.JournalFileOpenLock

class optuna.storages.JournalFileOpenLock(filepath)[source]

Lock class for synchronizing processes for NFSv3 or later.

On acquiring the lock, open system call is called with the O_EXCL option to create an exclusive file. The file is deleted when the lock is released. This class is only supported when using NFSv3 or later on kernel 2.6 or later. In prior NFS environments, use JournalFileSymlinkLock.

Parameters

filepath (str) – The path of the file whose race condition must be protected.

Methods

acquire()

Acquire a lock in a blocking way by creating a lock file.

release()

Release a lock by removing the created file.

acquire()[source]

Acquire a lock in a blocking way by creating a lock file.

Returns

True if it succeeded in creating a self._lock_file

Return type

bool

release()[source]

Release a lock by removing the created file.

Return type

None