Make serverRequestCall interruptible (#30)

Instead of making a blocking foreign call without a timeout, we set a
timeout of one second. This way, the thread returns in Haskell code (and
thus is interruptible) at least every second. This is useful in order to
be able to kill `Server`s, see
https://github.com/awakesecurity/gRPC-haskell/issues/22.
This commit is contained in:
Olivier Nicole 2017-08-21 17:35:05 +02:00 committed by intractable
parent e0c567ec55
commit 679e3d7ded

View File

@ -50,7 +50,14 @@ serverRequestCall s scq ccq =
runExceptT $ case ce of
C.CallOk -> do
ExceptT $ do
r <- pluck' scq tag Nothing
let
rec = do
-- yield every second, for interruptibility
r <- pluck' scq tag (Just 1)
case r of
Left GRPCIOTimeout -> rec
_ -> return r
r <- rec
dbug $ "pluck' finished: " ++ show r
return r
lift $