From: khaines@... Date: 2006-08-31T01:23:44+09:00 Subject: Re: problem using pstore with multi-users On Thu, 31 Aug 2006, James Edward Gray II wrote: >> pstore doesn't itself do any locking of any sort. > > I don't think that's accurate. Here's part of the transaction() method for > PStore. Note the calls to flock(): > > def transaction(read_only=false) # :yields: pstore > # ... > > unless read_only > file = File.open(@filename, File::RDWR | File::CREAT) > file.binmode > file.flock(File::LOCK_EX) > commit_new(file) if FileTest.exist?(new_file) > content = file.read() > else > begin > file = File.open(@filename, File::RDONLY) > file.binmode > file.flock(File::LOCK_SH) > content = (File.read(new_file) rescue file.read()) > rescue Errno::ENOENT > content = "" > end > end Well now, that's really interesting, because I never had anything but misery when I tried using pstore in a context where two threads or processes would try to access the same file at the same time. This has me very curious as to why. Fiddlesticks! Kirk Haines