pararun: don't swallow failures

This commit is contained in:
Mamy Ratsimbazafy 2022-09-18 23:37:35 +02:00
parent 2f6144fb7a
commit cc47c27cca
No known key found for this signature in database
GPG Key ID: 6227262F49BE273A

View File

@ -66,8 +66,10 @@ proc releaseOnProcessExit(sem: AsyncSemaphore, p: AsyncProcess) {.async.} =
# #
# see also: https://forum.nim-lang.org/t/5565 # see also: https://forum.nim-lang.org/t/5565
var backoff = 8
while p.running(): while p.running():
await sleepAsync(10) backoff = min(backoff*2, 1024) # Exponential backoff
await sleepAsync(backoff)
sem.release() sem.release()
proc enqueuePendingCommands(wq: WorkQueue) {.async.} = proc enqueuePendingCommands(wq: WorkQueue) {.async.} =
@ -96,6 +98,10 @@ proc flushCommandsOutput(wq: WorkQueue) {.async.} =
let charsWritten = stdout.writeBuffer(wq.lineBuf[0].addr, charsRead) let charsWritten = stdout.writeBuffer(wq.lineBuf[0].addr, charsRead)
doAssert charsRead == charsWritten doAssert charsRead == charsWritten
let exitCode = p.peekExitCode()
if exitCode != 0:
quit exitCode
if wq.cmdQueue.len == 0 and wq.outputQueue.len == 0: if wq.cmdQueue.len == 0 and wq.outputQueue.len == 0:
return return