X-Git-Url: http://dolda2000.com/gitweb/?p=didex.git;a=blobdiff_plain;f=didex%2Fstore.py;h=a9bf0cdc6c34db06434b90c6b5d042b9d66480c1;hp=55dc71eeb4cf7d14544fb443a1e3b4e01303de63;hb=a19ad473ae0a534f454dadacb01d8252ab51c21f;hpb=36c0a0110bb357edb6c167e9abc1a689106c3f05 diff --git a/didex/store.py b/didex/store.py index 55dc71e..a9bf0cd 100644 --- a/didex/store.py +++ b/didex/store.py @@ -1,4 +1,4 @@ -import threading, pickle, inspect +import threading, pickle, inspect, atexit from . import db, index, cache from .db import txnfun @@ -22,11 +22,13 @@ class environment(object): if self.path is None: self.path = self.getpath() self.bk = db.environment(self.path, recover=self.recover) + atexit.register(self.close) return self.bk def close(self): with self.lk: if self.bk is not None: + atexit.unregister(self.close) self.bk.close() self.bk = None @@ -42,7 +44,7 @@ def storedescs(obj): for nm, val in st.__dict__.items(): if isinstance(val, storedesc): ret.append((nm, val)) - t.__dict__["__didex_attr"] = ret + t.__didex_attr = ret return ret class datastore(object):