[Haskell-cafe] two problems with Data.Binary and Data.ByteString

Tim Newsham newsham at lava.net
Tue Aug 12 20:34:44 EDT 2008


>>>   Log: savedState.bin: openFile: resource busy (file is locked)
>>> 
>>> this does not occur if the program wasnt loaded.  My best guess here
>>> is that B.readFile isnt completing and closing the file for some
>>> reason.  Is there a good way to force this?
>> 
>> Lazy IO. So force the result to be evaluated, and then close the handle,
>> or use strict bytestring reading.
>
> There is no visible handle.  It's all hidden in readFile.
> I will try forcing the data.

I tried to force the data with:

     loadState db = do
         d <- decode <$> B.readFile stateFile
         let force = sum $ M.elems $ M.size `fmap` d
         force `seq` atomically $ writeTVar db d

and I get the same error when trying to writeFile after doing
a loadState.

>> -- Don

Tim Newsham
http://www.thenewsh.com/~newsham/


More information about the Haskell-Cafe mailing list