From 5135952c9c7d84fbad514a9f693f7e785e90b603 Mon Sep 17 00:00:00 2001 From: yuyi Date: Wed, 15 Jun 2022 16:59:53 +0800 Subject: [PATCH] v.util: add a retry loop for tool compilation in launch_tool() (#14760) --- vlib/v/util/util.v | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/vlib/v/util/util.v b/vlib/v/util/util.v index 12e0372348..5a631f5fc7 100644 --- a/vlib/v/util/util.v +++ b/vlib/v/util/util.v @@ -176,10 +176,19 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) { if is_verbose { println('Compiling $tool_name with: "$compilation_command"') } - tool_compilation := os.execute_or_exit(compilation_command) - if tool_compilation.exit_code != 0 { - eprintln('cannot compile `$tool_source`: \n$tool_compilation.output') - exit(1) + + retry_max_count := 3 + for i in 0 .. retry_max_count { + tool_compilation := os.execute(compilation_command) + if tool_compilation.exit_code == 0 { + break + } else { + if i == retry_max_count - 1 { + eprintln('cannot compile `$tool_source`: \n$tool_compilation.output') + exit(1) + } + time.sleep(20 * time.millisecond) + } } } $if windows {