Skip to content

Commit 965a7f9

Browse files
committed
feature: Disable locking behavior
feature: Disable locking behavior in lockfile.py to prevent issues with large batches where many jobs may try to access the lockfile at one time.
1 parent cafd63d commit 965a7f9

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/pylada/misc/lockfile.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,31 @@ def lock(self):
7474
pass
7575
start_time = time.time()
7676
# loops until acqires lock.
77+
# colton_mod_start
7778
while self._owns_lock == False:
7879
# tries to create director.
7980
try:
8081
self._owns_lock = True
8182
mkdir(self.lock_directory)
8283
# if fails, then another process already created it. Just keep looping.
8384
except error:
84-
self._owns_lock = False
85+
pass
86+
# self._owns_lock = False
87+
# time.sleep(self.sleep)
88+
# colton_mod_end
8589
# 2013-11-11: disable timeout to make it try forever,
8690
# since timeouts are causing large runs to fail.
8791
# if self.timeout is not None:
8892
# if time.time() - start_time > self.timeout:
8993
# raise RuntimeError("Could not acquire lock on file {0}.".format(self.filename))
90-
time.sleep(self.sleep)
9194

9295
def __del__(self):
9396
""" Deletes hold on object. """
94-
if self.owns_lock:
95-
self.release()
97+
# colton_mod_start
98+
# if self.owns_lock:
99+
# self.release()
100+
return
101+
# colton_mod_end
96102

97103
def __enter__(self):
98104
""" Enters context. """
@@ -132,16 +138,13 @@ def release(self):
132138
It is also an error to release a lock which is not locked.
133139
Makes sure things are syncro. The latter is an internal bug though.
134140
"""
135-
from os import rmdir
136-
assert self._owns_lock, IOError("Filelock object does not own lock.")
137-
assert self.is_locked, IOError("Filelock object owns an unlocked lock.")
141+
# colton_mod_start
142+
# from os import rmdir
143+
# assert self._owns_lock, IOError("Filelock object does not own lock.")
144+
# assert self.is_locked, IOError("Filelock object owns an unlocked lock.")
138145
self._owns_lock = False
139-
rmdir(self.lock_directory)
140-
141-
def __del__(self):
142-
""" Releases lock if still held. """
143-
if self.owns_lock and self.is_locked:
144-
self.release()
146+
# rmdir(self.lock_directory)
147+
# colton_mod_end
145148

146149
def remove_stale(self):
147150
""" Removes a stale lock. """

0 commit comments

Comments
 (0)