
Hi Alex. I'm testing thespian in rss2irc, FYI: http://joyful.com/darcsden/simon/rss2irc/browse/rss2irc.hs#L-114 . Maybe there's a better way to use it, but for now it brings me one extra thread and higher memory usage/leakage - an instance grew to 350M overnight where I'd normally see 50-100M. The leak may be in my code, but I haven't found it yet. Did you notice high memory usage when using thespian ? Whether or not I end up keeping it, it has influenced the ordinary thread-based manager for the better, eg see forkMonitoredIO which is like a poor man's monitor using exceptions rather than actor messages. Best, - Simon On Oct 12, 2011, at 8:44 AM, Simon Michael wrote:
Hi Alex, thanks for the reply (it didn't seem to reach haskell-cafe, if that matters) and the update on status. I passed over CloudHaskell as it seemed (a) over-complex for my needs and (b) not ready, eg not on hackage. I need something that will still permit cabal install rss2irc. But perhaps that's not far off. I'll look again more closely, at both.
Best - Simon
On Oct 11, 2011, at 10:48 PM, Alex Constandache wrote:
Hi Simon,
Sorry for the late reply. I no longer work on thespian, as there is another project, called Cloud Haskell which provides much more functionality than thespian (including Erlang style distributed computing). It is not available on Hackage, but it lives on Github at
https://github.com/jepst/CloudHaskell
Simon Peyton-Johnes himself seems to be associated with the project, so you should have a look at it. If it does not match your needs, feel free to hack thespian and send me a pull request on bitbucket. You are the second person who emailed about thespian in the last month, so maybe I should reconsider the decision to abandon it (which was motivated by my desire to avoid contributing to the insane fragmentation that plagues Hackage).
--Alex
On Sun, Oct 9, 2011 at 12:45 PM, Simon Michael
wrote: Hi Alexander, I went looking for something to clean up rss2irc's thread management, and your recently released thespian package looks like the simplest, most practical actors/erlang/OTP-ish lib for haskell so far. Thanks! I need to restart threads (actors) in a controlled way when they die or hang. I think some of all of that is also part of Erlang/OTP, and maybe it's already on your todo list. Here are some notes I made, for your interest and in case you have any further thoughts. I thought of adding some actor-transforming combinators like these: -- | Spawn the specified action and restart it whenever it dies, unless -- the restart frequency exceeds any of the given maximum frequencies in -- which case throw an exception. restart :: [Frequency] -> IO a -> IO Address restart fs action = spawn $ do setFlag TrapRemoteExceptions let start times = [] forever t <- getCurrentTime update start times when (any fs exceeded by start times) throw error worker <- spawn action monitor worker receive worker [Case _ -> return ()] -- | Convert hangs to exceptions using a watchdog timer: spawn the -- specified action under the control of a watcher which monitors it and -- also kills it and throws an exception if the worker ever fails to -- send (something) to the watcher within the specified interval. watchdog :: Seconds -> (Address -> IO a) -> IO Address watchdog t action = spawn $ do watcher <- self worker <- spawn $ action watcher monitor worker forever receiveTimeout t [Case _ -> return () Default -> throw error ] which I would use something like: main = do (feed, bot) <- ... spawn $ do reader <- restart [MaxPerHour 2] $ watchdog 60 $ feedReader feed bot announcer <- restart [MaxPerHour 2] $ watchdog 60 $ ircAnnouncer bot responder <- restart [MaxPerHour 2] $ watchdog 60 $ ircResponder bot monitor reader monitor announcer monitor responder setFlag TrapRemoteExceptions receive [Case e :: RemoteException -> exitFailure (show e) -- one of the above died or hung too frequently ] but the types aren't right. I'm not sure if these combinators are possible with the current thespian api. Also they would complicate things, eg what is the address of a restarted actor ? On second thoughts it might be better if these features were built in to the library. I imagine something like: main = do ... reader <- spawnWith [RestartSpec [MinInterval (minutes 5), MaxPerHour 3, MaxPerWeek 6], Watchdog (seconds 60)] $ feedReader feed bot feedReader = do forever poll feed, do stuff resetWatchdog What do you think ? Best - Simon
-- AC I used to have a signature, but now I don't.
-----BEGIN PGP PUBLIC KEY BLOCK----- Version: BCPG v1.45
mQINBE2kb5sBEADO/4u9AVkyz+jEnhgYzfdJ2tIIxOfAL4rqx2jXbxeFVq7vyBRS vM+K8u2Xw2TBC0dXzNy9GiBf9qjZS1EGPPiIvTLsp5aIoQLsO7E6H6g7Z5eqijMC c4qhrnmWsxcOZv8s0iil6H6OXa/EQzP2M1DRmyU8W49Cvo+Jg9hHZGbvdqpNrmYZ ZV5cA9hTneAFe7wixfQ7GDu80dCELmwwWX2adVpeW5dyX0u42Bp7e263GU1wPWTY t5CTkrgvHkFu7Hu3SGt66Q95xvCkK/RFLJbKJyeuHOY3uIa6YWKtMCNPcFz9C520 D+MQElWU9xFssxXj626v/GhTGoOPKu948r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