file_lock

exception FileLockException[源代码]

基类:Exception

class FileLock(lock_file_path, timeout=- 1, delay=0.05)[源代码]

基类: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()[源代码]

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.

release()[源代码]

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