|
7 | 7 | import logging |
8 | 8 | import os |
9 | 9 | import requests |
| 10 | +import requests.exceptions |
10 | 11 | import subprocess |
11 | 12 | import sys |
12 | 13 | import time |
@@ -231,21 +232,27 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): |
231 | 232 | exit(1) |
232 | 233 |
|
233 | 234 | # 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 |
249 | 256 | # Wait before polling again |
250 | 257 | time.sleep(10) |
251 | 258 | else: |
|
0 commit comments