|
7 | 7 | import logging |
8 | 8 | import os |
9 | 9 | import requests |
10 | | -import requests.exceptions |
11 | 10 | import subprocess |
12 | 11 | import sys |
13 | 12 | import time |
@@ -231,29 +230,23 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): |
231 | 230 | print("Build failed.") |
232 | 231 | exit(1) |
233 | 232 |
|
234 | | - # Attempt to stream logs |
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 | 233 | # Wait before polling again |
256 | | - time.sleep(10) |
| 234 | + # time.sleep(10) |
| 235 | + # Attempt to stream logs rather than time.sleep |
| 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 | + sys.stdout.flush() |
| 246 | + else: |
| 247 | + logger.warning(f"Failed to stream logs: {log_resp.text}") |
| 248 | + time.sleep(10) # Wait before polling again |
| 249 | + |
257 | 250 | else: |
258 | 251 | # Log detailed information about the failed request |
259 | 252 | logger.error(f"Request failed with status code {resp.status_code}") |
|
0 commit comments