From 4fc706705521cd8fed60a0403c903a377516ea95 Mon Sep 17 00:00:00 2001 From: "Roger E. Masse" Date: Tue, 25 Mar 1997 16:06:03 +0000 Subject: [PATCH] Added a 'sync' method to shelve. If the underlying database does not have a sync attribute, this method silently ignores this fact. The default (bsddb's dbhash) does. --- Lib/shelve.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/shelve.py b/Lib/shelve.py index b05c627379a..8f709a233a0 100644 --- a/Lib/shelve.py +++ b/Lib/shelve.py @@ -72,6 +72,10 @@ class Shelf: def __del__(self): self.close() + def sync(self): + if hasattr(self.dict, 'sync'): + self.dict.sync() + class BsdDbShelf(Shelf): """Shelf implementation using the "BSD" db interface.