13 lines
316 B
Python
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
|