LuciferYang commented on code in PR #51149:
URL: https://github.com/apache/spark/pull/51149#discussion_r2214773479


##########
dev/run-tests.py:
##########
@@ -156,17 +157,39 @@ def exec_sbt(sbt_args=()):
         b"^.*[info].*Resolving" + b"|" + b"^.*[warn].*Merging" + b"|" + 
b"^.*[info].*Including"
     )
 
-    # NOTE: echo "q" is needed because sbt on encountering a build file
-    # with failure (either resolution or compilation) prompts the user for
-    # input either q, r, etc to quit or retry. This echo is there to make it
-    # not block.
-    echo_proc = subprocess.Popen(["echo", '"q\n"'], stdout=subprocess.PIPE)
-    sbt_proc = subprocess.Popen(sbt_cmd, stdin=echo_proc.stdout, 
stdout=subprocess.PIPE)
-    echo_proc.wait()
-    for line in iter(sbt_proc.stdout.readline, b""):
-        if not sbt_output_filter.match(line):
-            print(line.decode("utf-8"), end="")
-    retcode = sbt_proc.wait()
+    attempts = 0
+    while attempts < retry:
+        attempts += 1
+
+        # NOTE: echo "q" is needed because sbt on encountering a build file
+        # with failure (either resolution or compilation) prompts the user for
+        # input either q, r, etc to quit or retry. This echo is there to make 
it
+        # not block.
+        echo_proc = subprocess.Popen(["echo", '"q\n"'], stdout=subprocess.PIPE)
+        sbt_proc = subprocess.Popen(sbt_cmd, stdin=echo_proc.stdout, 
stdout=subprocess.PIPE)
+        echo_proc.wait()
+        for line in iter(sbt_proc.stdout.readline, b""):
+            if not sbt_output_filter.match(line):
+                print(line.decode("utf-8"), end="")
+        retcode = sbt_proc.wait()
+
+        if retcode == 0:
+            # successfully executed the command
+            return
+        elif attempts < retry:
+            # Will retry the command.
+            if retcode < 0:
+                print(
+                    "[error] running",
+                    " ".join(sbt_cmd),
+                    "; process was terminated by signal",
+                    -retcode,
+                )
+            else:
+                print("[error] running", " ".join(sbt_cmd), "; received return 
code", retcode)
+
+            time.sleep(10)
+            print("[info] Retrying command", sbt_cmd, "; attempt ", attempts + 
1, " of ", retry)

Review Comment:
   ```suggestion
               print("[info] Retrying command", " ".join(sbt_cmd), "; attempt 
", attempts + 1, " of ", retry)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to