mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-23 03:29:42 +01:00
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:
parent
e0c567ec55
commit
679e3d7ded
1 changed files with 8 additions and 1 deletions
|
@ -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 $
|
||||
|
|
Loading…
Reference in a new issue