low-end persistence strategies?

Paul Rubin http
Wed Feb 16 23:38:04 EST 2005


Jamey Cribbs <jcribbs at twmi.rr.com> writes:
> The only time there might be trouble is if two clients try to write to
> the same table (physical file) at the same time. 

Yes, that's what I'm concerned about.

> When it writes to a file, KirbyBase opens it in append mode (r+, I
> think).  My guess would be, whichever client got there first would
> open the file.  The second client, arriving a split second later,
> would attempt to open the file in append mode also and KirbyBase
> would return an exception.  If your cgi script caught and handled
> the exception, you would be fine.

I don't think the OS will stop both processes from opening in append
mode (which just means opening the file and seeking to the end) at
once unless you use O_EXCL or something.  Then you're left with
handling the exception, which may get messy if you want to have all
the corner cases correct.  It would be nice if there was a published
code snippet somewhere that did that.  I may try writing one.

The best solution, I think, is Michele Simionato's, which is to use
the currently-undocumented bsddb transction features.  Those features
are the right technical approach to this problem.  But they really
ought to get documented first.



More information about the Python-list mailing list