Hi!

On Wed, Nov 10, 2010 at 4:16 PM, Simon Marlow <marlo...@gmail.com> wrote:
> The right way to fix it is like this:

Optimist. ;-)

>  let run = unblock doSomething `catches` [
>                Handler (\(_ :: MyTerminateException) -> return ()),
>                Handler (\(e :: SomeException) -> putStrLn $ "Exception: " ++
> show e)
>              ] `finally` (putMVar terminated ())
>  nid <- block $ forkIO run

In 6.12.3 this does not work (it does not change anything, I hope I
tested it correctly) because finally is defined as:

a `finally` sequel =
  block (do
    r <- unblock a `onException` sequel
    _ <- sequel
    return r
  )

You see that unblock there? So it still unblocks so that second
exception is delivered immediately after catches handles the first
exception?

But I agree that your explanation for what is happening is the correct
one. Better than my "hanging threads at the end". And with my throwIO
approach I just override MyTerminateException with ThreadKilled.


Mitar
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to