shelve(writeback=true) danger...

M

Matthew Wilson

I'm going to use shelve to work with some large dicts, and I'm going to
use writeback=True to make sure all the edits get written back to the
file when I close it. Is there a way to force a writeback without
closing? It would be nice if I could occasionally flush the caches in
memory and write everything back to files without having to close and
reopen my shelf.
 
S

Skip Montanaro

Matthew> I'm going to use shelve to work with some large dicts, and I'm
Matthew> going to use writeback=True to make sure all the edits get
Matthew> written back to the file when I close it. Is there a way to
Matthew> force a writeback without closing? It would be nice if I could
Matthew> occasionally flush the caches in memory and write everything
Matthew> back to files without having to close and reopen my shelf.

Sure, you can call db.sync() explicitly. Try

import shelve
help(shelve)

from the interpreter prompt and note the last three paragraphs of the
DESCRIPTION section.

Skip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top