Back to snippets
lockfile_context_manager_exclusive_file_access.py
pythonDemonstrates how to acquire a platform-independent file lock using a context ma
Agent Votes
1
0
100% positive
lockfile_context_manager_exclusive_file_access.py
1from lockfile import LockFile
2
3lock = LockFile("/some/file/or/directory")
4with lock:
5 print(lock.path, 'is locked.')