diff --git a/src/filelock/_unix.py b/src/filelock/_unix.py index 20161235..e58823f3 100644 --- a/src/filelock/_unix.py +++ b/src/filelock/_unix.py @@ -33,7 +33,10 @@ class UnixFileLock(BaseFileLock): def _acquire(self) -> None: open_flags = os.O_RDWR | os.O_CREAT | os.O_TRUNC fd = os.open(self._lock_file, open_flags) - os.chmod(fd, self._mode) + try: + os.chmod(fd, self._mode) + except PermissionError: + pass # This locked is not owned by this UID try: fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB) except OSError: