Skip to content

Commit 869441e

Browse files
committed
error handling
1 parent e4f687b commit 869441e

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

chipflow_lib/steps/silicon.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import logging
88
import os
99
import requests
10+
import requests.exceptions
1011
import subprocess
1112
import sys
1213
import time
@@ -231,21 +232,27 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False):
231232
exit(1)
232233

233234
# Attempt to stream logs
234-
with requests.get(
235-
log_stream_url,
236-
auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]),
237-
stream=True
238-
) as log_resp:
239-
if log_resp.status_code == 200:
240-
for line in log_resp.iter_lines():
241-
if line:
242-
print(line.decode("utf-8")) # Print logs in real-time
243-
elif log_resp.status_code == 404:
244-
logger.error("Log streaming endpoint returned 404: Not Found.")
245-
print("Log streaming failed: Build not found.")
246-
exit(1) # Exit with failure
247-
else:
248-
logger.warning(f"Failed to stream logs: {log_resp.text}")
235+
try:
236+
with requests.get(
237+
log_stream_url,
238+
auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]),
239+
stream=True
240+
) as log_resp:
241+
if log_resp.status_code == 200:
242+
for line in log_resp.iter_lines():
243+
if line:
244+
print(line.decode("utf-8")) # Print logs in real-time
245+
elif log_resp.status_code == 404:
246+
logger.error("Log streaming endpoint returned 404: Not Found.")
247+
print("Log streaming failed: Build not found.")
248+
exit(1) # Exit with failure
249+
else:
250+
logger.warning(f"Failed to stream logs: {log_resp.text}")
251+
except requests.exceptions.ChunkedEncodingError as e:
252+
logger.error("Log streaming failed due to a premature response termination.")
253+
logger.error(f"Error details: {e}")
254+
print("Log streaming interrupted. Please check the build status manually.")
255+
exit(1) # Exit with failure
249256
# Wait before polling again
250257
time.sleep(10)
251258
else:

0 commit comments

Comments
 (0)