* added optional wait interval for retry{ ... }

This commit is contained in:
Reinhard Pointner 2012-12-09 14:03:34 +00:00
parent b770ecb6af
commit 35e95c3a43
1 changed files with 2 additions and 1 deletions

View File

@ -365,7 +365,7 @@ def tryQuietly(c) {
/**
* Retry given closure until it returns successfully (indefinitely by default)
*/
def retry(n = -1, quiet = false, c) {
def retry(n = -1, wait = 0, quiet = false, c) {
for(int i = 0; n < 0 || i <= n; i++) {
try {
return c.call()
@ -375,6 +375,7 @@ def retry(n = -1, quiet = false, c) {
} else if (!quiet) {
_log.warning("retry $i: ${e.class.simpleName}: ${e.message}")
}
sleep(wait)
}
}
}