Dolda2000 GitWeb
/
didex.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
abb94f8
)
Improved environment initialization.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Fri, 20 Mar 2015 05:14:59 +0000
(06:14 +0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Fri, 20 Mar 2015 05:14:59 +0000
(06:14 +0100)
didex/store.py
patch
|
blob
|
blame
|
history
diff --git
a/didex/store.py
b/didex/store.py
index
15d2eca
..
450a9fe
100644
(file)
--- a/
didex/store.py
+++ b/
didex/store.py
@@
-3,15
+3,23
@@
from . import db, index, cache
from .db import txnfun
class environment(object):
from .db import txnfun
class environment(object):
- def __init__(self, path):
- self.path = path
+ def __init__(self, *, path=None, getpath=None, recover=False):
+ if path is not None:
+ self.path = path
+ self.getpath = None
+ else:
+ self.path = None
+ self.getpath = getpath
+ self.recover = recover
self.lk = threading.Lock()
self.bk = None
def __call__(self):
with self.lk:
if self.bk is None:
self.lk = threading.Lock()
self.bk = None
def __call__(self):
with self.lk:
if self.bk is None:
- self.bk = db.environment(self.path)
+ if self.path is None:
+ self.path = self.getpath()
+ self.bk = db.environment(self.path, recover=self.recover)
return self.bk
def close(self):
return self.bk
def close(self):
@@
-41,7
+49,7
@@
class store(object):
if env:
self.env = env
else:
if env:
self.env = env
else:
- self.env = environment(path)
+ self.env = environment(path
=path
)
self._db = None
if ncache is None:
ncache = cache.cache()
self._db = None
if ncache is None:
ncache = cache.cache()