File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,17 @@ File("release-notes.txt").writeText(text)
5555// TODO: Duplicate; use the retry.main.kts script.
5656// See other scripts for example usage.
5757// NOTE that currently, IntelliJ code features break when importing external scripts.
58+ /* *
59+ * Try [forAtMost] times to run the block without exception.
60+ *
61+ * We could also make subsequent runs wait
62+ * for an [exponential delay](https://en.wikipedia.org/wiki/Exponential_backoff).
63+ * See [this article](https://dzone.com/articles/understanding-retry-pattern-with-exponential-back).
64+ *
65+ * I wrote this function myself.
66+ * It is interesting that [this solution](https://stackoverflow.com/a/46890009)
67+ * proposed by Roman Elizarov is very similar to mine.
68+ */
5869fun <T > tryTo (
5970 description : String ,
6071 forAtMost : Int = 5,
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import kotlin.time.toDuration
1212val waitTime = 10 .toDuration(DurationUnit .SECONDS )
1313
1414/* *
15- * Try for at most [retryCount ] times to run the block without exception.
15+ * Try [forAtMost ] times to run the block without exception.
1616 *
1717 * We could also make subsequent runs wait
1818 * for an [exponential delay](https://en.wikipedia.org/wiki/Exponential_backoff).
You can’t perform that action at this time.
0 commit comments