Skip to content

Commit 5135952

Browse files
authored
v.util: add a retry loop for tool compilation in launch_tool() (#14760)
1 parent 7f38b92 commit 5135952

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

vlib/v/util/util.v

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,19 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) {
176176
if is_verbose {
177177
println('Compiling $tool_name with: "$compilation_command"')
178178
}
179-
tool_compilation := os.execute_or_exit(compilation_command)
180-
if tool_compilation.exit_code != 0 {
181-
eprintln('cannot compile `$tool_source`: \n$tool_compilation.output')
182-
exit(1)
179+
180+
retry_max_count := 3
181+
for i in 0 .. retry_max_count {
182+
tool_compilation := os.execute(compilation_command)
183+
if tool_compilation.exit_code == 0 {
184+
break
185+
} else {
186+
if i == retry_max_count - 1 {
187+
eprintln('cannot compile `$tool_source`: \n$tool_compilation.output')
188+
exit(1)
189+
}
190+
time.sleep(20 * time.millisecond)
191+
}
183192
}
184193
}
185194
$if windows {

0 commit comments

Comments
 (0)