Skip to content

Commit

Permalink
Fix FileLock.acquire_ctx only releasing on errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aiudirog committed Jul 1, 2021
1 parent e2351fc commit ae7537e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aiuti/filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def acquire_ctx(self,
raise TimeoutError("Failed to acquire file lock:", self._lock_file)
try:
yield
except BaseException: # noqa
finally:
self.release()

def release(self, force: bool = False) -> None:
Expand Down
2 changes: 1 addition & 1 deletion aiuti/tests/test_filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_acquire_ctx(flock: FileLock) -> None:
"""Same as test_simple but using acquire_ctx."""
with flock.acquire_ctx() as lock:
assert flock.is_locked
assert flock is lock
assert lock is None
assert not flock.is_locked


Expand Down

0 comments on commit ae7537e

Please sign in to comment.