Skip to content

Commit 5ed5b8d

Browse files
committed
make sure it's OK to call remove_lock on a lock that's no longer there
1 parent 5800437 commit 5ed5b8d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

easybuild/tools/filetools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,8 @@ def remove_lock(lock_name):
15321532
lock_path = det_lock_path(lock_name)
15331533
_log.info("Removing lock %s...", lock_path)
15341534
remove_dir(lock_path)
1535-
global_lock_names.remove(lock_name)
1535+
if lock_name in global_lock_names:
1536+
global_lock_names.remove(lock_name)
15361537
_log.info("Lock removed: %s", lock_path)
15371538

15381539

test/framework/filetools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,6 +2431,9 @@ def test_locks(self):
24312431
ft.remove_lock(lock_name)
24322432
self.assertFalse(os.path.exists(lock_path))
24332433

2434+
# no harm done if remove_lock is called if lock is already gone
2435+
ft.remove_lock(lock_name)
2436+
24342437
# check_lock just returns again after lock is removed
24352438
ft.check_lock(lock_name)
24362439

0 commit comments

Comments
 (0)