shelve: writing out updates?!

Robert Kern rkern at ucsd.edu
Sat Jul 30 20:57:17 EDT 2005


Paul Rubin wrote:
> Shelve uses dbm and pickle to make a persistent object store.  The
> "db" in "dbm" stands for "database" and while I didn't expect full
> ACID capability, I'd have thought there'd be at least some minimum
> gesture towards durability of updates.  But say that s is a shelve
> object.  If I say
> 
>    s[whatever] = value
> 
> there is no way apparent from the shelve docs to get the update
> flushed out to the disk file until the shelve is actually closed.  If
> I'm using the shelve to store stuff in a long-running server, it could
> be months before the shelve closes.
> 
> Is shelve really missing this capability?  

No. Call the .sync() method. Unfortunately, the shelve module is not 
well-documented.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Python-list mailing list