Skip to content
Snippets Groups Projects
Commit 8d1ec0df authored by Michael Kuhn's avatar Michael Kuhn Committed by Todd Gamblin
Browse files

Fix read locks on read-only file systems (#1857)

parent 6c627dba
No related branches found
No related tags found
No related merge requests found
...@@ -70,7 +70,8 @@ def _lock(self, op, timeout): ...@@ -70,7 +70,8 @@ def _lock(self, op, timeout):
while (time.time() - start_time) < timeout: while (time.time() - start_time) < timeout:
try: try:
if self._fd is None: if self._fd is None:
self._fd = os.open(self._file_path, os.O_RDWR) mode = os.O_RDWR if op == fcntl.LOCK_EX else os.O_RDONLY
self._fd = os.open(self._file_path, mode)
fcntl.lockf(self._fd, op | fcntl.LOCK_NB) fcntl.lockf(self._fd, op | fcntl.LOCK_NB)
if op == fcntl.LOCK_EX: if op == fcntl.LOCK_EX:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment