Fix file locks in NFS-mounted directories (#517)

Fix #515.
pull/525/head
FYY 8 months ago committed by GitHub
parent 5ce4f1a159
commit a2484b3053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -56,7 +56,7 @@ def get_server_throughput(
# We use the system-wide lock since only one process at a time can measure the host throughput
os.makedirs(lock_path.parent, exist_ok=True)
with open(lock_path, "wb") as lock_fd:
with open(lock_path, "wb+") as lock_fd:
logger.info("Loading throughput info")
fcntl.flock(lock_fd.fileno(), fcntl.LOCK_EX)
# The OS will release the lock when lock_fd is closed or the process is killed

@ -22,7 +22,7 @@ def _blocks_lock(cache_dir: Optional[str], mode: int):
lock_path = Path(cache_dir, BLOCKS_LOCK_FILE)
os.makedirs(lock_path.parent, exist_ok=True)
with open(lock_path, "wb") as lock_fd:
with open(lock_path, "wb+") as lock_fd:
fcntl.flock(lock_fd.fileno(), mode)
# The OS will release the lock when lock_fd is closed or the process is killed
yield

Loading…
Cancel
Save