diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2003-09-27 23:00:19 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2003-09-27 23:00:19 (GMT) |
commit | 1eb41e22ab4288bef5883ee93d04e87f5b1fb5ca (patch) | |
tree | e5d734c4041100c63c9c48479902e615716dd252 /Lib/bsddb/__init__.py | |
parent | c8083cf1cc375fa4df828a8a2241cf6617c111f4 (diff) | |
download | cpython-1eb41e22ab4288bef5883ee93d04e87f5b1fb5ca.zip cpython-1eb41e22ab4288bef5883ee93d04e87f5b1fb5ca.tar.gz cpython-1eb41e22ab4288bef5883ee93d04e87f5b1fb5ca.tar.bz2 |
Use a threadsafe private DBEnv for each bsddb compatibility interface
db that is opened. DB_THREAD and DB_INIT_LOCK allow for multithreaded
access. DB_PRIVATE prevents the DBEnv from using the filesystem
(making it only usable by this process; and in this implementation
using one DBEnv per bsddb database)
Diffstat (limited to 'Lib/bsddb/__init__.py')
-rw-r--r-- | Lib/bsddb/__init__.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/bsddb/__init__.py b/Lib/bsddb/__init__.py index 4671acc..51cc454 100644 --- a/Lib/bsddb/__init__.py +++ b/Lib/bsddb/__init__.py @@ -189,7 +189,8 @@ def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None, cachesize=None, lorder=None, hflags=0): flags = _checkflag(flag) - d = db.DB() + e = _openDBEnv() + d = db.DB(e) d.set_flags(hflags) if cachesize is not None: d.set_cachesize(0, cachesize) if pgsize is not None: d.set_pagesize(pgsize) @@ -206,7 +207,8 @@ def btopen(file, flag='c', mode=0666, pgsize=None, lorder=None): flags = _checkflag(flag) - d = db.DB() + e = _openDBEnv() + d = db.DB(e) if cachesize is not None: d.set_cachesize(0, cachesize) if pgsize is not None: d.set_pagesize(pgsize) if lorder is not None: d.set_lorder(lorder) @@ -224,7 +226,8 @@ def rnopen(file, flag='c', mode=0666, rlen=None, delim=None, source=None, pad=None): flags = _checkflag(flag) - d = db.DB() + e = _openDBEnv() + d = db.DB(e) if cachesize is not None: d.set_cachesize(0, cachesize) if pgsize is not None: d.set_pagesize(pgsize) if lorder is not None: d.set_lorder(lorder) @@ -238,6 +241,10 @@ def rnopen(file, flag='c', mode=0666, #---------------------------------------------------------------------- +def _openDBEnv(): + e = db.DBEnv() + e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL) + return e def _checkflag(flag): if flag == 'r': |