Skip to content

Commit

Permalink
Add error if file fails to generate
Browse files Browse the repository at this point in the history
  • Loading branch information
kdumontnu committed Oct 27, 2023
1 parent 88114bc commit f40211a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 6 additions & 3 deletions allspice/utils/bom_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,13 @@ def _extract_all_schdoc_components(

all_components = []
# If the file is not yet generated, we'll retry a few times.
while any(retry_counter):
while any(i > 0 for i in retry_counter):
for idx in range(len(retry_counter)):
if retry_counter[idx] <= 0:
if retry_counter[idx] < 0:
continue
elif retry_counter[idx] == 0:
raise Exception(
f"Fetching file {schdoc_files_in_repo[idx].path} in {repository} ref={ref} exceeded max retries.")

retry_counter[idx] -= 1

Expand All @@ -272,7 +275,7 @@ def _extract_all_schdoc_components(
attributes_mapping,
)
)
retry_counter[idx] = 0
retry_counter[idx] = -1
except NotYetGeneratedException:
pass
if any(retry_counter):
Expand Down
9 changes: 3 additions & 6 deletions allspice/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@ def get_all_pcb_components(
"""

retry_count = 0
while True:
while retry_count < 60:
retry_count += 1
try:
pcb_json = repository.get_generated_json(pcb_file, ref=ref)
break
return pcb_json["component_instances"]
except NotYetGeneratedException:
if retry_count > 60:
break
# Wait a bit before retrying.
time.sleep(0.25)
continue

return pcb_json["component_instances"]
raise Exception(f"Fetching file {pcb_file} in {repository} ref={ref} exceeded max retries.")

0 comments on commit f40211a

Please sign in to comment.