exception FileLockException[source]

Bases: Exception

class FileLock(lock_file_path, timeout=- 1, delay=0.05)[source]

Bases: object

A file locking mechanism that has context-manager support so you can use it in a with statement. This should be relatively cross compatible as it doesn’t rely on msvcrt or fcntl for the locking.


Acquire the lock, if possible. If the lock is in use, it check again every wait seconds. It does this until it either gets the lock or exceeds timeout number of seconds, in which case it throws an exception.


Get rid of the lock by deleting the lockfile. When working in a with statement, this gets automatically called at the end.