Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/SCons/scons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2023-10-04 19:26:44 +0300
committerMats Wichmann <mats@linux.com>2023-10-04 19:26:44 +0300
commitb4103361f4a1334a0ad94227630632b1711f9cc0 (patch)
treed7f19315970a2a2301245f9e97b56e9ae1480040
parent0a3801e98adb96f3d8641036b59c177f843b86bd (diff)
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 <mats@linux.com>
-rw-r--r--SCons/Tool/MSCommon/common.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/SCons/Tool/MSCommon/common.py b/SCons/Tool/MSCommon/common.py
index fd61c1d58..f8816c4f0 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: