title: throwTo warp tls thread hangs idefinetly
body: <p>I have a Yesod app with a warp server, and some of its functionality depends on async exceptions. Recently there arose a need to migrate it to https, which I did with the package <code>warp-tls</code>. However now I can't kill the warp thread by throwing <code>ThreadKilled</code> exceptions at it, the <code>throwTo</code> function just hangs and does nothing.</p>
  
  <p>Consider the following example. Here we monitor the state of warp thread with <code>MVar ()</code>, which is empty while the thread is running, and has a () value when the thread is killed.</p>
  
  <pre class="lang-hs prettyprint-override"><code>import MyApplication (waiPage)
  -- waiPage :: Application
  
  runWai :: MVar () -&gt; IO ()
  runWai finishVar = bracket
    (return ())
    (const $ putMVar finishVar ())
    (const runApp)
    where
      -- change this to normal or tls to check
      runApp = runAppTls
      runAppNormal = runSettings warpSettings waiPage
      runAppTls = runTLS siteTlsSettings warpSettings waiPage
      --
      warpSettings = setPort 8080 defaultSettings
      siteTlsSettings = tlsSettings "cert.pem" "key.pem"
  
  
  
  main :: IO ()
  main = do
    finishVar &lt;- newEmptyMVar
    thread_id &lt;- forkIO $ runWai finishVar
    -- Try to kill warp thread. Fork because throw might hang
    forkIO $ throwTo thread_id ThreadKilled
    threadDelay (2 * 10^6) -- microseconds to seconds
    isAlive &lt;- isEmptyMVar finishVar
    if isAlive then putStrLn "Couldn't kill warp thread"
               else putStrLn "Succesfully killed warp thread"
    -- Wait for forked warp thread to finish
    readMVar finishVar
  </code></pre>
  
  <p>When you have <code>runApp = runAppNormal</code>, you will get <code>Succesfully killed warp thread</code> message, and the application will exit.</p>
  
  <p>When you have <code>runApp = runAppTls</code>, you will get the <code>Couldn't kill warp thread</code> message, and the app will hang and keep serving.</p>
  
  <p>So how do I get rid of this exception-intercepting behavior? Or at Least is there a way to kill the warpTls thread in any other way?</p>