Skip to content

Commit

Permalink
Fix FileFreeLock (#578)
Browse files Browse the repository at this point in the history
fix FileFreeLock
  • Loading branch information
lhoestq authored Apr 18, 2024
1 parent 7a18c55 commit b337370
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/evaluate/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ class FileFreeLock(BaseFileLock):
def __init__(self, lock_file, *args, **kwargs):
self.filelock = FileLock(lock_file)
super().__init__(lock_file, *args, **kwargs)
self._lock_file_fd = None

def _acquire(self):
try:
self.filelock.acquire(timeout=0.01, poll_intervall=0.02) # Try to lock once
self.filelock.acquire(timeout=0.01, poll_interval=0.02) # Try to lock once
except Timeout:
# We couldn't acquire the lock, the file is locked!
self._lock_file_fd = self.filelock.lock_file
Expand All @@ -62,6 +63,10 @@ def _acquire(self):
def _release(self):
self._lock_file_fd = None

@property
def is_locked(self) -> bool:
return self._lock_file_fd is not None


# lists - summarize long lists similarly to NumPy
# arrays/tensors - let the frameworks control formatting
Expand Down

0 comments on commit b337370

Please sign in to comment.