From 7ef387becf068473fd53bfba7d958b956b6c9c02 Mon Sep 17 00:00:00 2001 From: Jaswant Panchumarti Date: Tue, 11 Nov 2025 06:32:22 -0500 Subject: [PATCH] Suppress potential errors when releasing filelocks on unix - closes #24609 - The `WindowsFileLock` class already has a suppression in place around `os.remove`. This commit adds a similar supression for `UnixFileLock` - These errors are typically raised when another instance of `emcc` released the lock file. This is a common pattern in the build systems of large projects. Ex: `ninja -j32` --- tools/filelock.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/filelock.py b/tools/filelock.py index 3c41dbcf45568..74b2e6baf6207 100644 --- a/tools/filelock.py +++ b/tools/filelock.py @@ -37,6 +37,7 @@ # Modules # ------------------------------------------------ +from contextlib import suppress import logging import os import threading @@ -410,8 +411,12 @@ def _acquire(self): def _release(self): fd = self._lock_file_fd self._lock_file_fd = None - os.unlink(self._lock_file) - fcntl.flock(fd, fcntl.LOCK_UN) + # Probably another instance of the application + # that released the file lock. + with suppress(FileNotFoundError): + os.unlink(self._lock_file) + with suppress(OSError): + fcntl.flock(fd, fcntl.LOCK_UN) os.close(fd) return None