turn off "thread blocked indefinitely in an STM transaction"?

I find the following mildly annoying: Prelude> import Control.Concurrent.STM Prelude Control.Concurrent.STM> atomically retry *** Exception: thread blocked indefinitely in an STM transaction Is there a way to not raise this exception, and block the thread? I don't see this behaviour (raising the exception) mentioned in the API docs nor in the defining paper (Composable memory transactions, PPoPP'05) that is referenced there. I understand it might come in handy for debugging, but sometimes (e.g., for teaching) I might really want a transaction that never commits. For instance, I am forkIO'ing some worker threads and the main program really should do absolutely nothing. So I thought I could just block the main thread. I can make some work-around with forM [1..n] $ \ p -> ( if p < n then void . forkIO else id ) $ forever $ do but that feels clumsy (since asymmetric). - J.W.

Is there a way to not raise this exception, and block the thread?
You can always prevent these blocked indefinitely exceptions by making a stable pointer to the threadId. This works because using ThreadId an Exception could be thrown to that thread, which would cause it to continue (and not block indefinitely). https://ghc.haskell.org/trac/ghc/ticket/10759 Cheers Silvio
participants (2)
-
Johannes Waldmann
-
Silvio Frischknecht