From cc47c27cca196fae2d1408f9ff20886a92041925 Mon Sep 17 00:00:00 2001 From: Mamy Ratsimbazafy Date: Sun, 18 Sep 2022 23:37:35 +0200 Subject: [PATCH] pararun: don't swallow failures --- helpers/pararun.nim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/helpers/pararun.nim b/helpers/pararun.nim index 8eeff4b..788d7b9 100644 --- a/helpers/pararun.nim +++ b/helpers/pararun.nim @@ -66,8 +66,10 @@ proc releaseOnProcessExit(sem: AsyncSemaphore, p: AsyncProcess) {.async.} = # # see also: https://forum.nim-lang.org/t/5565 + var backoff = 8 while p.running(): - await sleepAsync(10) + backoff = min(backoff*2, 1024) # Exponential backoff + await sleepAsync(backoff) sem.release() proc enqueuePendingCommands(wq: WorkQueue) {.async.} = @@ -95,6 +97,10 @@ proc flushCommandsOutput(wq: WorkQueue) {.async.} = break let charsWritten = stdout.writeBuffer(wq.lineBuf[0].addr, charsRead) doAssert charsRead == charsWritten + + let exitCode = p.peekExitCode() + if exitCode != 0: + quit exitCode if wq.cmdQueue.len == 0 and wq.outputQueue.len == 0: return