Skip to content

Commit 7dfee10

Browse files
committed
Fix flaky local endpoint list when reading concurrent/empty cache files
1 parent 14cd162 commit 7dfee10

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

sdk/ml/azure-ai-ml/azure/ai/ml/operations/_local_endpoint_helper.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,14 @@ def list(self) -> Iterable[OnlineEndpoint]:
121121
endpoint_stubs = self._endpoint_stub.list()
122122
# Iterate through all cached endpoint files
123123
for endpoint_file in endpoint_stubs:
124-
endpoint_json = json.loads(endpoint_file.read_text())
124+
try:
125+
contents = endpoint_file.read_text()
126+
if not contents.strip():
127+
continue
128+
endpoint_json = json.loads(contents)
129+
except (json.JSONDecodeError, OSError):
130+
# Skip files being written concurrently or otherwise unreadable
131+
continue
125132
container = self._docker_client.get_endpoint_container(
126133
endpoint_name=endpoint_json.get("name"), include_stopped=True
127134
)

0 commit comments

Comments
 (0)