|
6 | 6 | import logging |
7 | 7 | import os |
8 | 8 | import requests |
| 9 | +import requests.exceptions |
9 | 10 | import subprocess |
10 | 11 | import time |
11 | 12 |
|
@@ -206,21 +207,27 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): |
206 | 207 | exit(1) |
207 | 208 |
|
208 | 209 | # Attempt to stream logs |
209 | | - with requests.get( |
210 | | - log_stream_url, |
211 | | - auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]), |
212 | | - stream=True |
213 | | - ) as log_resp: |
214 | | - if log_resp.status_code == 200: |
215 | | - for line in log_resp.iter_lines(): |
216 | | - if line: |
217 | | - print(line.decode("utf-8")) # Print logs in real-time |
218 | | - elif log_resp.status_code == 404: |
219 | | - logger.error("Log streaming endpoint returned 404: Not Found.") |
220 | | - print("Log streaming failed: Build not found.") |
221 | | - exit(1) # Exit with failure |
222 | | - else: |
223 | | - logger.warning(f"Failed to stream logs: {log_resp.text}") |
| 210 | + try: |
| 211 | + with requests.get( |
| 212 | + log_stream_url, |
| 213 | + auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]), |
| 214 | + stream=True |
| 215 | + ) as log_resp: |
| 216 | + if log_resp.status_code == 200: |
| 217 | + for line in log_resp.iter_lines(): |
| 218 | + if line: |
| 219 | + print(line.decode("utf-8")) # Print logs in real-time |
| 220 | + elif log_resp.status_code == 404: |
| 221 | + logger.error("Log streaming endpoint returned 404: Not Found.") |
| 222 | + print("Log streaming failed: Build not found.") |
| 223 | + exit(1) # Exit with failure |
| 224 | + else: |
| 225 | + logger.warning(f"Failed to stream logs: {log_resp.text}") |
| 226 | + except requests.exceptions.ChunkedEncodingError as e: |
| 227 | + logger.error("Log streaming failed due to a premature response termination.") |
| 228 | + logger.error(f"Error details: {e}") |
| 229 | + print("Log streaming interrupted. Please check the build status manually.") |
| 230 | + exit(1) # Exit with failure |
224 | 231 | # Wait before polling again |
225 | 232 | time.sleep(10) |
226 | 233 | else: |
|
0 commit comments