Skip to content
This repository was archived by the owner on Nov 9, 2021. It is now read-only.

Latest commit

 

History

History
20 lines (14 loc) · 481 Bytes

File metadata and controls

20 lines (14 loc) · 481 Bytes

FileLock

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.

Usage

from filelock import FileLock

with FileLock("myfile.txt"):
    # work with the file as it is now locked
    print("Lock acquired.")

Originally posted at http://www.evanfosmark.com/2009/01/cross-platform-file-locking-support-in-python/