[Tutor] Immediately committing changes to shelve files

Kent Johnson kent37 at tds.net
Mon Oct 27 12:18:16 CET 2008

On Sun, Oct 26, 2008 at 10:37 PM, Mike Meisner <mikem at blazenetme.net> wrote:
> I'm running a number of test cases and saving their results in a shelve
> file.
> A full run of the test cases takes about 36 hours.  During that time, if
> something interrupts the run (e.g., a power outage, which has happened), I
> find that none of the completed test cases have been committed to the shelve
> file even though, after each run, I make sure that the results are written
> to the in-memory database (i.e., db = shelve.open(filename) at the beginning
> of the test run; and db[key] = results after each test case).
> Is there a way to force the results for a single test case to be written
> back to the shelve file?  Other than opening/closing the shelve after each
> test case run?

I think the sync() method might do this, depending on which
implementation of dbm your shelf is using.


More information about the Tutor mailing list