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

This commit is contained in:
Michael Kuhn 2016-09-30 18:45:08 +02:00 committed by Todd Gamblin
parent 6c627dbac9
commit 8d1ec0df3d

View File

@ -70,7 +70,8 @@ def _lock(self, op, timeout):
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: