
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. Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://ertes.de/

On Mon, Jan 31, 2011 at 1:09 PM, Ertugrul Soeylemez
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

Michael Snoyman
On Mon, Jan 31, 2011 at 1:09 PM, Ertugrul Soeylemez
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?
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.
Thank you for your quick reply. How are my chances to get patches to Yesod incorporated into the mainstream code? Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://ertes.de/

On Mon, Jan 31, 2011 at 2:28 PM, Ertugrul Soeylemez
Michael Snoyman
wrote: On Mon, Jan 31, 2011 at 1:09 PM, Ertugrul Soeylemez
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?
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.
Thank you for your quick reply. How are my chances to get patches to Yesod incorporated into the mainstream code?
If it's a clean patch and does not break backwards compatibility: very high. If it's a clean patch that *does* break backwards compatibility: still good, but you'll have to wait till a major release. For not-so-clean patches, I suppose it depends on how dirty we're talking ;). Michael

Michael Snoyman
On Mon, Jan 31, 2011 at 1:09 PM, Ertugrul Soeylemez
wrote: 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?
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.
I've run into the first problem with this. Without having to use subsites, what's an easy method to use wai-handler-devel with such a setup? Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://ertes.de/

On Thu, Feb 3, 2011 at 3:14 PM, Ertugrul Soeylemez
Michael Snoyman
wrote: On Mon, Jan 31, 2011 at 1:09 PM, Ertugrul Soeylemez
wrote: 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?
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.
I've run into the first problem with this. Without having to use subsites, what's an easy method to use wai-handler-devel with such a setup?
I believe the new architecture in use for wai-handler-devel 0.2 (which will work with Yesod 0.7) should work properly with multi-threaded apps. But yes, there's no easy way to do this with the current wai-handler-devel. Michael
participants (2)
-
Ertugrul Soeylemez
-
Michael Snoyman