vmmgr/usr/lib/python3.6/lxcmgr/flock.py
2019-09-20 10:10:25 +02:00

13 lines
316 B
Python

# -*- coding: utf-8 -*-
import fcntl
def flock_ex(lock_file):
def decorator(target):
def wrapper(*args, **kwargs):
with open(lock_file, 'w') as lock:
fcntl.lockf(lock, fcntl.LOCK_EX)
return target(*args, **kwargs)
return wrapper
return decorator