提交 86a06c61 authored 作者: nouiz's avatar nouiz

Merge pull request #744 from yaoli/compile_lock

Compile lock minor change
...@@ -36,24 +36,24 @@ def force_unlock(): ...@@ -36,24 +36,24 @@ def force_unlock():
timeout_before_override = timeout_backup timeout_before_override = timeout_backup
def get_lock(**kw): def get_lock(lock_dir=None, **kw):
""" """
Obtain lock on compilation directory. Obtain lock on compilation directory.
:param kw: Additional arguments to be forwarded to the `lock` function when :param kw: Additional arguments to be forwarded to the `lock` function when
acquiring the lock. acquiring the lock.
""" """
if lock_dir is None:
lock_dir = os.path.join(config.compiledir, 'lock_dir')
if not hasattr(get_lock, 'n_lock'): if not hasattr(get_lock, 'n_lock'):
# Initialization. # Initialization.
get_lock.n_lock = 0 get_lock.n_lock = 0
if not hasattr(get_lock, 'lock_is_enabled'): if not hasattr(get_lock, 'lock_is_enabled'):
# Enable lock by default. # Enable lock by default.
get_lock.lock_is_enabled = True get_lock.lock_is_enabled = True
get_lock.lock_dir = os.path.join(config.compiledir, get_lock.lock_dir = lock_dir
'lock_dir')
get_lock.unlocker = Unlocker(get_lock.lock_dir) get_lock.unlocker = Unlocker(get_lock.lock_dir)
else: else:
lock_dir = os.path.join(config.compiledir, 'lock_dir')
if lock_dir != get_lock.lock_dir: if lock_dir != get_lock.lock_dir:
# Compilation directory has changed. # Compilation directory has changed.
# First ensure all old locks were released. # First ensure all old locks were released.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论