File tree 1 file changed +6
-2
lines changed
modules/build/src/main/scala/scala/build
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,13 @@ package scala
3
3
import scala .annotation .tailrec
4
4
import scala .concurrent .duration .DurationConversions .*
5
5
import scala .concurrent .duration .{DurationInt , FiniteDuration }
6
+ import scala .util .Random
6
7
7
8
package object build {
8
9
def retry [T ](
9
10
maxAttempts : Int = 3 ,
10
- waitDuration : FiniteDuration = 1 .seconds
11
+ waitDuration : FiniteDuration = 1 .seconds,
12
+ variableWaitDelayInMs : Int = 500
11
13
)(logger : Logger )(
12
14
run : => T
13
15
): T = {
@@ -21,7 +23,9 @@ package object build {
21
23
else {
22
24
t.getStackTrace.foreach(ste => logger.debug(ste.toString))
23
25
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)
25
29
helper(count + 1 )
26
30
}
27
31
}
You can’t perform that action at this time.
0 commit comments