[Haskell-cafe] Yesod and concurrency

Michael Snoyman michael at snoyman.com
Mon Jan 31 12:49:34 CET 2011


On Mon, Jan 31, 2011 at 1:09 PM, Ertugrul Soeylemez <es at ertes.de> wrote:
> Hello everybody,
>
> how well do WAI, Yesod and the 'persistent' package play with
> concurrency?  For example, I'd like to write a program, which
> concurrently provides two related sites as well as a few background
> workers, which do something with the database.  My idea would look
> something like this:
>
>  main :: IO ()
>  main =
>    withMyAppPool $ \pool -> do
>      forkIO $ worker1 ...   -- background worker
>      forkIO $ worker2 ...   -- background worker
>      forkIO $ worker3 ...   -- background worker
>      forkIO $ toWaiApp ...  -- site 1
>      forkIO $ toWaiApp ...  -- site 2
>
> Will I run into problems with this?
>
> Thanks.

There should not be any issues, just make sure you compile with
-threaded. The persistent database connection pool should work just
fine for this. If you find any issues, please let me know, but I have
not had trouble in the past.

Michael



More information about the Haskell-Cafe mailing list