Time limits: with time.block and time.each
In the terminalela --spec time-limits-with-time-block-and-time-each
with time.block bounds a wait. Every line of its block ends within the limit, its loops and jobs
included.
ela <<'EOF'proc fetch_all(repos: list) with time.block = "2m" for r in $repos git -C $r fetch end for end withend proc err = try fetch_all(["api", "web"])if error.is($err, Error.TIMEOUT) echo "the fetch took too long: $err"end ifEOF
- Past the limit, the script stops at the
withline, names the line that was running and exits 124. tryon a proc that holds the block gives an Error of kindError.TIMEOUTinstead, and the script goes on.with time.each = "30s"gives each command of the block its own limit. One past it is ended and exits 124, whichtryon it gives as anError.TIMEOUT, and the block goes on. One command alone is the one-line form, ela's own fortimeout 20 git status:
with time.each = "20s"; out, err = try $(git status)if error.is($err, Error.TIMEOUT) echo "git status did not answer in 20s"end if
(ela --spec time-block-and-time-each)