Issue #23865: close() methods in multiple modules now are idempotent and more

robust at shutdown. If needs to release multiple resources, they are released
even if errors are occured.
This commit is contained in:
Serhiy Storchaka 2015-04-10 13:24:41 +03:00
parent 842f00e725
commit 7e7a3dba5f
27 changed files with 299 additions and 197 deletions

View file

@ -248,8 +248,10 @@ class _Database(collections.MutableMapping):
raise error('DBM object has already been closed') from None
def close(self):
self._commit()
self._index = self._datfile = self._dirfile = self._bakfile = None
try:
self._commit()
finally:
self._index = self._datfile = self._dirfile = self._bakfile = None
__del__ = close