Skip to content

Commit 21588c5

Browse files
7487claude
andcommitted
refactor: narrow put error handling to os.replace per review
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: 7487 <1042653432@qq.com>
1 parent d03c005 commit 21588c5

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎sqlmesh/utils/cache.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ def put(self, name: str, entry_id: str = "", *, value: T) -> None:
136136
with os.fdopen(tmp_fd, "wb") as raw_fd:
137137
with gzip.open(raw_fd, "wb", compresslevel=1) as fd:
138138
pickle.dump(value, fd)
139-
os.replace(tmp_name, self._cache_entry_path(name, entry_id))
140-
except OSError as ex:
141-
# Storing an entry is best-effort; e.g. on Windows os.replace fails if a
142-
# concurrent reader still has the target file open.
143-
logger.warning("Failed to store a cache entry '%s': %s", name, ex)
139+
try:
140+
os.replace(tmp_name, self._cache_entry_path(name, entry_id))
141+
except OSError as ex:
142+
# Windows os.replace fails if a concurrent reader still has the target file open.
143+
logger.warning("Failed to store a cache entry '%s': %s", name, ex)
144144
finally:
145145
try:
146146
os.unlink(tmp_name)

0 commit comments

Comments
 (0)