import Control.Monadimport Control.Monad.Trans.Classimport Control.Monad.IO.Classimport Data.Conduitimport Data.Conduit.Listimport System.Environmentimport System.IO{- | Accept file paths on input, output opened file handle, and ensure that the- handle is always closed after its downstream pipe finishes whatever work on it. -}fileConduit :: MonadResource m => IOMode -> Conduit FilePath m HandlefileConduit mode = awaitForever processwhereprocess file = bracketP (openFile file mode) closeWithMsg yieldcloseWithMsg h = doputStrLn "Closing file"hClose h{- | Print the first line from each handle on input. Don't care about the handle. -}firstLine :: MonadIO m => Sink Handle m ()firstLine = awaitForever (liftIO . (hGetLine >=> putStrLn))main = doargs <- getArgsrunResourceT $ sourceList args =$= fileConduit ReadMode $$ firstLine
Hi,I am working on an automation that periodically fetches bug data from our bug tracking system and creates static HTML reports. Things worked fine when the bugs were in the order of 200 or so. Now I am trying to run it against 3000 bugs and suddenly I see things like - too many open handles, out of memory etc ...Here's the code snippet - http://hpaste.org/84197It's a small snippet and I've put in the comments stating how I run into "out of file handles" or simply file not getting read due to lazy IO.I realize that putting ($!) using a trial/error approach is going to be futile. I'd appreciate some pointers into the tools I could use to get some idea of which expressions are building up huge thunks.Regards,Kashyap
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe