File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
modules/build/src/main/scala/scala/build Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,13 @@ package scala
33import scala .annotation .tailrec
44import scala .concurrent .duration .DurationConversions .*
55import scala .concurrent .duration .{DurationInt , FiniteDuration }
6+ import scala .util .Random
67
78package object build {
89 def retry [T ](
910 maxAttempts : Int = 3 ,
10- waitDuration : FiniteDuration = 1 .seconds
11+ waitDuration : FiniteDuration = 1 .seconds,
12+ variableWaitDelayInMs : Int = 500
1113 )(logger : Logger )(
1214 run : => T
1315 ): T = {
@@ -21,7 +23,9 @@ package object build {
2123 else {
2224 t.getStackTrace.foreach(ste => logger.debug(ste.toString))
2325 logger.log(s " Caught $t, trying again in $waitDuration… " )
24- Thread .sleep(waitDuration.toMillis)
26+ val variableDelay = Random .between(0 , variableWaitDelayInMs + 1 ).milliseconds
27+ val currentWaitDuration = waitDuration + variableDelay
28+ Thread .sleep(currentWaitDuration.toMillis)
2529 helper(count + 1 )
2630 }
2731 }
You can’t perform that action at this time.
0 commit comments