The following program hangs indefinitely:
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveAnyClass #-}
module Main where
import Control.Monad
import Control.Exception
import Control.Concurrent
import Control.Concurrent.STM
import Ki
data Bang = Bang
deriving (Exception, Show)
main :: IO ()
main =
scoped \scope1 -> do
explodingThread <- fork scope1 do
threadDelay 1_000_000
throwIO Bang
scoped \ki -> do
c <- newTChanIO
threadId <- fork ki do
forever do
atomically do
readTChan c
putStrLn "Waiting"
threadDelay 10_000_000
I would expect this to be fine, and die with the Bang exception. If we use a single scope, that's exactly what happens, so it seems to be some kind of interation between two scopes.
The following program hangs indefinitely:
{-# LANGUAGE BlockArguments #-} {-# LANGUAGE DeriveAnyClass #-} module Main where import Control.Monad import Control.Exception import Control.Concurrent import Control.Concurrent.STM import Ki data Bang = Bang deriving (Exception, Show) main :: IO () main = scoped \scope1 -> do explodingThread <- fork scope1 do threadDelay 1_000_000 throwIO Bang scoped \ki -> do c <- newTChanIO threadId <- fork ki do forever do atomically do readTChan c putStrLn "Waiting" threadDelay 10_000_000I would expect this to be fine, and die with the
Bangexception. If we use a single scope, that's exactly what happens, so it seems to be some kind of interation between two scopes.