[racket] call-with-timeout

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Nov 15 17:18:14 EST 2013

Two hours ago, Neil Van Dyke wrote:
> If I want to have a procedure or syntax that evaluates a block of
> code with a timeout, and it needs to be perfectly reliable[*], then
> is the below "call-with-timeout" procedure the way to do it?
> [...]

Not a direct answer -- but did you consider `call-with-limits'?  IIUC,
you could do something like this:

  (define (call-with-timeout ... same ...)
    (with-handlers ([exn:fail:resource?
                     (if timeout-proc (λ(e) (timeout-proc)) void)])
      (call-with-limits timeout-seconds #f proc)))

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.