Lars Kuhtz | 28 Mar 21:00 2013
Picon

warp and http-conduit on concurrent threads on windows

Hi,

I'd like to know what is wrong with the following program on windows8 
(GHC 7.4.2, 32bit):

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Main where

import Control.Concurrent.Async
import qualified Control.Exception as E
import Network.HTTP.Conduit
import Network.HTTP.Types
import Network.Wai
import Network.Wai.Handler.Warp

query port = E.catch
     (simpleHttp ("http://haskell.org:" ++ show port) >>= print . take 
10 . show)
     (\(e :: HttpException) -> print $ "caught: " ++ show e)

listen = run 8080 $ \_ ->
     return $ responseLBS ok200 [] "abc"

main = do
     withAsync (query 12345) $ \a -> do
     withAsync listen $ \b -> do
     wait a
     wait b
(Continue reading)

Felipe Almeida Lessa | 28 Mar 21:26 2013
Picon

Re: warp and http-conduit on concurrent threads on windows

Quick tip: did you try using withSocketsDo[1]?

[1] http://hackage.haskell.org/packages/archive/network/2.4.1.2/doc/html/Network.html#g:2

On Thu, Mar 28, 2013 at 5:00 PM, Lars Kuhtz <haskell <at> kuhtz.eu> wrote:
> Hi,
>
> I'd like to know what is wrong with the following program on windows8 (GHC
> 7.4.2, 32bit):
>
> {-# LANGUAGE OverloadedStrings #-}
> {-# LANGUAGE ScopedTypeVariables #-}
>
> module Main where
>
> import Control.Concurrent.Async
> import qualified Control.Exception as E
> import Network.HTTP.Conduit
> import Network.HTTP.Types
> import Network.Wai
> import Network.Wai.Handler.Warp
>
> query port = E.catch
>     (simpleHttp ("http://haskell.org:" ++ show port) >>= print . take 10 .
> show)
>     (\(e :: HttpException) -> print $ "caught: " ++ show e)
>
> listen = run 8080 $ \_ ->
>     return $ responseLBS ok200 [] "abc"
>
(Continue reading)

Lars Kuhtz | 28 Mar 21:41 2013
Picon

Re: warp and http-conduit on concurrent threads on windows

Good point, forgot about that in the reduced example. However, adding 
it does not change the described behavior.

On 2013-03-28 13:26, Felipe Almeida Lessa wrote:
> Quick tip: did you try using withSocketsDo[1]?
>
> [1]
> 
> http://hackage.haskell.org/packages/archive/network/2.4.1.2/doc/html/Network.html#g:2
>
> On Thu, Mar 28, 2013 at 5:00 PM, Lars Kuhtz <haskell <at> kuhtz.eu> wrote:
>> Hi,
>>
>> I'd like to know what is wrong with the following program on 
>> windows8 (GHC
>> 7.4.2, 32bit):
>>
>> {-# LANGUAGE OverloadedStrings #-}
>> {-# LANGUAGE ScopedTypeVariables #-}
>>
>> module Main where
>>
>> import Control.Concurrent.Async
>> import qualified Control.Exception as E
>> import Network.HTTP.Conduit
>> import Network.HTTP.Types
>> import Network.Wai
>> import Network.Wai.Handler.Warp
>>
>> query port = E.catch
(Continue reading)


Gmane