Skip to content

Commit fdec76b

Browse files
committed
When gyb-generation fails on a subthread, raise that exception in the parent thread
An exception raised in a thread managed by `ThreadPoolExecutor` only gets raised if its value is retrieved. Iterate over all the 'None' results to cause the exceptions to be propagated. Otherwise, gyb-generation can silently fail.
1 parent c9042c0 commit fdec76b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

build-script.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,13 @@ def generate_gyb_file(gyb_file: str) -> None:
230230
# files if they haven't changed and don't trigger a rebuild.
231231
gyb_files = [file for file in os.listdir(sources_dir) if file.endswith(".gyb")]
232232
with ThreadPoolExecutor() as executor:
233-
executor.map(generate_gyb_file, gyb_files)
233+
results = executor.map(generate_gyb_file, gyb_files)
234+
# An exception raised in a thread managed by `ThreadPoolExecutor` only gets
235+
# raised if its value is retrieved. Iterate over all the 'None' results to cause
236+
# the exceptions to be propagated.
237+
for _ in results:
238+
pass
239+
234240

235241

236242
# Generate the syntax node `.swift` files from `SyntaxNodes.swift.gyb.template`.

0 commit comments

Comments
 (0)