vmmgr/usr/lib/python3.6/lxcmgr/flock.py

13 lines
316 B
Python
Raw Normal View History

2019-09-20 10:10:25 +02:00
# -*- 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