From b4103361f4a1334a0ad94227630632b1711f9cc0 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Wed, 4 Oct 2023 10:26:44 -0600 Subject: Further mod on msvc config cache locking In the first iteration, we took a read lock in the read case. A fail was observed where the reader took a json decode error, and then tried to remove the cachefile in case it's really corrupt. That failed as the file was "busy" - on Windows removing is essentially writing the file - so take a write lock here too. Signed-off-by: Mats Wichmann --- SCons/Tool/MSCommon/common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SCons/Tool/MSCommon/common.py b/SCons/Tool/MSCommon/common.py index fd61c1d..f8816c4 100644 --- a/SCons/Tool/MSCommon/common.py +++ b/SCons/Tool/MSCommon/common.py @@ -119,10 +119,12 @@ def read_script_env_cache() -> dict: p = Path(CONFIG_CACHE) if not CONFIG_CACHE or not p.is_file(): return envcache - with SCons.Util.FileLock(CONFIG_CACHE, timeout=5), p.open('r') as f: + with SCons.Util.FileLock(CONFIG_CACHE, timeout=5, writer=True), p.open('r') as f: # Convert the list of cache entry dictionaries read from # json to the cache dictionary. Reconstruct the cache key # tuple from the key list written to json. + # Note we need to take a write lock on the cachefile, as if there's + # an error and we try to remove it, that's "writing" on Windows. try: envcache_list = json.load(f) except json.JSONDecodeError: -- cgit v0.12