Skip to content

Commit b24f2d1

Browse files
committed
fix
fix
1 parent c999d2e commit b24f2d1

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

dev/run-tests.py

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import os
2323
import re
2424
import sys
25+
import time
2526
import subprocess
2627

2728
from sparktestsupport import SPARK_HOME, USER_HOME, ERROR_CODES
@@ -146,7 +147,7 @@ def exec_maven(mvn_args=()):
146147
run_cmd(flags + mvn_args)
147148

148149

149-
def exec_sbt(sbt_args=()):
150+
def exec_sbt(sbt_args=(), retry=1):
150151
"""Will call SBT in the current directory with the list of mvn_args passed
151152
in and returns the subprocess for any further processing"""
152153

@@ -156,17 +157,39 @@ def exec_sbt(sbt_args=()):
156157
b"^.*[info].*Resolving" + b"|" + b"^.*[warn].*Merging" + b"|" + b"^.*[info].*Including"
157158
)
158159

159-
# NOTE: echo "q" is needed because sbt on encountering a build file
160-
# with failure (either resolution or compilation) prompts the user for
161-
# input either q, r, etc to quit or retry. This echo is there to make it
162-
# not block.
163-
echo_proc = subprocess.Popen(["echo", '"q\n"'], stdout=subprocess.PIPE)
164-
sbt_proc = subprocess.Popen(sbt_cmd, stdin=echo_proc.stdout, stdout=subprocess.PIPE)
165-
echo_proc.wait()
166-
for line in iter(sbt_proc.stdout.readline, b""):
167-
if not sbt_output_filter.match(line):
168-
print(line.decode("utf-8"), end="")
169-
retcode = sbt_proc.wait()
160+
attempts = 0
161+
while attempts < retry:
162+
attempts += 1
163+
164+
# NOTE: echo "q" is needed because sbt on encountering a build file
165+
# with failure (either resolution or compilation) prompts the user for
166+
# input either q, r, etc to quit or retry. This echo is there to make it
167+
# not block.
168+
echo_proc = subprocess.Popen(["echo", '"q\n"'], stdout=subprocess.PIPE)
169+
sbt_proc = subprocess.Popen(sbt_cmd, stdin=echo_proc.stdout, stdout=subprocess.PIPE)
170+
echo_proc.wait()
171+
for line in iter(sbt_proc.stdout.readline, b""):
172+
if not sbt_output_filter.match(line):
173+
print(line.decode("utf-8"), end="")
174+
retcode = sbt_proc.wait()
175+
176+
if retcode == 0:
177+
# successfully executed the command
178+
return
179+
elif attempts < retry:
180+
# Will retry the command.
181+
if retcode < 0:
182+
print(
183+
"[error] running",
184+
" ".join(sbt_cmd),
185+
"; process was terminated by signal",
186+
-retcode,
187+
)
188+
else:
189+
print("[error] running", " ".join(sbt_cmd), "; received return code", retcode)
190+
191+
time.sleep(10)
192+
print("[info] Retrying command", sbt_cmd, "; attempt ", attempts + 1, " of ", retry)
170193

171194
if retcode != 0:
172195
exit_from_command_with_retcode(sbt_cmd, retcode)
@@ -255,7 +278,7 @@ def build_spark_sbt(extra_profiles):
255278

256279
print("[info] Building Spark using SBT with these arguments: ", " ".join(profiles_and_goals))
257280

258-
exec_sbt(profiles_and_goals)
281+
exec_sbt(profiles_and_goals, retry=3)
259282

260283

261284
def build_spark_unidoc_sbt(extra_profiles):

0 commit comments

Comments
 (0)