summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/llnl/util/lock.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/spack/llnl/util/lock.py b/lib/spack/llnl/util/lock.py
index aa8272d5fe..b5e3a3a8f8 100644
--- a/lib/spack/llnl/util/lock.py
+++ b/lib/spack/llnl/util/lock.py
@@ -70,7 +70,8 @@ class Lock(object):
while (time.time() - start_time) < timeout:
try:
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)
if op == fcntl.LOCK_EX: