I must have tried it wrong the first time, because I see what you see.
I'm surprised that `with-limits` doesn't shut down a custodian on a
timeout, but you can set up that termination yourself:
(parameterize ([current-subprocess-custodian-mode 'kill]
[current-custodian
Hi,
I want to run a subprocess with a timeout. Here’s what I tried:
#lang racket
(require racket/sandbox)
(with-handlers ([exn:fail:resource? (λ (e) (displayln "Timed out"))])
(with-limits 5 #f (system "sleep 10 && echo Finished")))
This doesn’t work, it prints both “Timed out” after 5
At Fri, 20 Jul 2018 16:28:22 -0400, "'Leandro Facchinetti' via Racket Users"
wrote:
> Hi,
>
> I want to run a subprocess with a timeout. Here’s what I tried:
>
> #lang racket
> (require racket/sandbox)
>
> (with-handlers ([exn:fail:resource? (λ (e) (displayln "Timed out"))])
> (with-limits 5
I thought `current-subprocess-custodian-mode` would be the solution, but
when I just tried your code (with Racket 6.12 on Mac OS), it first printed
"Timed out", then printed “Finished” after a brief delay.
I get the same result if I put the `parameterize` directly around the call
to `system`, and
4 matches
Mail list logo