提交 304919ea authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Fixed bug where 'lock_dir' directories were creating in wrong locations

Also fixed potential crash within a race condition (os.sleep => time.sleep).
上级 45881a7d
...@@ -113,7 +113,7 @@ def lock(tmp_dir, timeout=120, min_wait=5, max_wait=10, verbosity=1): ...@@ -113,7 +113,7 @@ def lock(tmp_dir, timeout=120, min_wait=5, max_wait=10, verbosity=1):
@type verbosity: int @type verbosity: int
""" """
# Create base of lock directory if required. # Create base of lock directory if required.
base_lock = os.path.basename(tmp_dir) base_lock = os.path.dirname(tmp_dir)
if not os.path.isdir(base_lock): if not os.path.isdir(base_lock):
try: try:
os.makedirs(base_lock) os.makedirs(base_lock)
...@@ -121,7 +121,7 @@ def lock(tmp_dir, timeout=120, min_wait=5, max_wait=10, verbosity=1): ...@@ -121,7 +121,7 @@ def lock(tmp_dir, timeout=120, min_wait=5, max_wait=10, verbosity=1):
# Someone else was probably trying to create it at the same time. # Someone else was probably trying to create it at the same time.
# We wait two seconds just to make sure the following assert does # We wait two seconds just to make sure the following assert does
# not fail on some NFS systems. # not fail on some NFS systems.
os.sleep(2) time.sleep(2)
assert os.path.isdir(base_lock) assert os.path.isdir(base_lock)
# Variable initialization. # Variable initialization.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论