nimble
nimble copied to clipboard
`nimble install --retry:N` for network commands that can fail
testament uses: discard tryCommand("nimble install --depsOnly -y", maxRetries = 3)
(which calls retryCall
) so that it retries on error, but that's not satisfying because only networkd commands should be retried.
IMO this should be done by nimble via a -retry:N
flag that would apply the retry logic with exponential backoff
This can be done in multiple ways, eg:
# inside nimble:
from std/private/gitutils import retryCall
(refs https://github.com/nim-lang/Nim/pull/16856)
example
-
getTagsListRemote
often flakes with for eg:
PASS: nimfp c (14.34 sec)
FAIL: nimgen c
Test "nimgen" in category "nimble-packages-2"
Failure: reInstallFailed
nimble install --depsOnly -y
Verifying dependencies for [email protected]
Info: Dependency on c2nim@>= 0.9.14 already satisfied
Verifying dependencies for [email protected]
Installing regex@>= 0.12.0
Downloading nitely/nim-regex using git
download.nim(93) getTagsListRemote
Error: unhandled exception: Unable to query remote tags for nitely/nim-regex. Git returned: fatal: unable to access 'nitely/nim-regex': Could not resolve host: github.com
[OSError]
This sounds like it can be implemented fairly easily. But thinking about it some more, the challenge with this is how we execute processes. AFAIK we block on their execution so this will be quite a big change :/
what I have in mind is actually a small change, not a big change: replacing network calls like:
var (output, exitCode) = doCmdEx("git ls-remote --tags " & url.quoteShell())
if exitCode != QuitSuccess:
raise newException(OSError, ...)
with:
from std/private/gitutils import retryCall
...
var output: string
let ok = retryCall(maxRetry = 3, backoffDuration = 1.0):
var exitCode: int
(output, exitCode) = doCmdEx("git ls-remote --tags " & url.quoteShell())
status == QuitSuccess
if not ok:
raise newException(OSError, ...)
it's still blocking, but this shouldn't matter much as this would only fail in rare events of network failures