anydbm safe for simultaneous writes?
Brian Smith
brian at briansmith.org
Thu Feb 28 08:47:23 EST 2008
Chris wrote:
> I need simple data persistence for a cgi application that
> will be used potentially by multiple clients simultaneously.
> So I need something that can handle locking among writes.
> Sqlite probably does this, but I am using Python 2.4.4, which
> does not include sqlite. The dbm-style modules would
> probably be fine, but I have no idea if they are "write safe"
> (I have no experience with the underlying unix stuff). Any
> tips appreciated.
No, you cannot assume that this will work without locking. Locking is
not trivial to do in Python. And, even with a working locking mechanism,
you still have to invalidate the in-memory caches any time a write to
the database is done. Futher, most dbm modules do not have ACID
properties.
I suggest intalling the pysqlite module and using it, regardless of your
version of CPython. According to pysqlite developer, the version of
pysqlite included in CPython 2.5 is old.
- Brian
More information about the Python-list
mailing list