[racket-dev] engine-kill from racket/engine

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jun 25 05:02:42 EDT 2013

I think that has to be a bug, and so a repair would be welcome.

At Tue, 25 Jun 2013 01:44:11 -0400, Asumu Takikawa wrote:
> Hi all,
> 
> I was trying to write an example for the racket/engine docs and stumbled
> on a case that seems to cause a deadlock. I'm curious if this is
> intentional or just accidental behavior.
> 
> Here's the example:
> 
>   #lang racket
>   (require racket/engine)
>   (define e (engine (lambda (s) (sleep 5))))
>   (thread (lambda () (sleep 2) (engine-kill e)))
>   (engine-run never-evt e)
> 
> This will never terminate. If you comment out the fourth line, it will
> terminate. If you change `never-evt` to 4000 (or any other event that
> will become ready), it's also fine.
> 
> What seems to be going on is that `engine-kill` does actually kill the
> thread underlying the engine. However, `engine-run` is `sync`ed on (1)
> the given event (2) the engine being "done" or (3) an exception being
> raised.  Since `engine-kill` does not trigger any of those, the `sync`
> is blocked.
> 
> Cheers,
> Asumu
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev

Posted on the dev mailing list.